logo

Babylon.js Market

PokerAIRandy

tabletop-casino · poker-ai

PokerAIRandy

Listens toPokerBetting
Talks toPokerBetting
1
Roulette RandyBonus figureRoulette Randy
Unlock

Install with the CLI:

bjs download PokerAIRandy

PokerAIRandy

Randy is the maniac seat — a poker NPC that picks uniformly at random from whatever the betting director offers, ignoring the cards entirely.

What it does

Randy's whole decision is one line: take the menu of legal actions and pick one at random. No equity read, no pot odds, no starting-hand tier. He folds, calls, and shoves all-in with the same odds, so he's the noise floor a table is tuned against — if a tighter personality can't beat Randy over a session, it isn't reading the cards.

The pure pick is randyDecision(actions, rng?). rng returns a float in [0, 1) and the index is floor(rng() * actions.length); an empty menu returns 'fold' so a caller always gets a legal-shaped action. createRandyStrategy(rng?) binds an rng into a callback shaped like PokerBetting's NpcStrategy(playerId, availableActions, context?) — that ignores both the seat id and the context. randy is that callback bound to Math.random.

PokerAIRandySystem plugs Randy into the bus on the same poker.actionRequiredpoker.turnAction protocol the default PokerAI brain uses. Swap the component into a scene and the seat plays loose instead of by-the-book. It still writes a hand label onto the context for a HUD (shortHand + classifyStartingHand from PokerAI), tagged with a note that the pick ignored the cards.

Use it in a scene

A scene is just data — a list of entities, each with its components. At startup the SceneLoader turns this JSON into a live world; edit the file and reload to rebuild it.

Fastest path

bjs download scene PokerAIRandy

Pulls this exact scene into your project and runs it — no copy-paste. Add --all to grab the components and assets it needs too.

Or build it from scratch with the bjs CLI:

  1. 1Scaffold a project
    npm create @babylonjsmarket/arcade@latest my-game

    World, renderer, and dev server — ready to run.

  2. 2Install dependencies
    cd my-game && npm install
  3. 3Add PokerAIRandy
    bjs download PokerAIRandy

    Copies its source into src/ so the scene resolves.

    First time? Run bjs login once.

  4. 4Paste the scene into src/scenes/arcade-room.ts and run
    npm run dev

    SceneLoader builds the world from the JSON; reload to rebuild.

JSON
{
  "Maniac": {
    "components": {
      "PokerAIRandy": {
        "seatIds": ["npc0", "npc1"]
      }
    }
  }
}

The example scene pairs it with PokerHandEval and PokerBetting: the director offers a menu on poker.actionRequired, Randy answers with poker.turnAction, the director applies the chip effect. Or register the strategy callback directly on the betting component for a per-seat mix of personalities:

TypeScript
import { createRandyStrategy } from './PokerAIRandy'
import { makeSeededRng } from './rng'

const strategies = new Map()
strategies.set('npc0', createRandyStrategy(makeSeededRng(42)))
bettingSystem.setStrategies(strategies)

Props

PropTypeDefaultMeaning
seatIdsstring[][]Seats this brain plays. Empty means it answers for every NPC seat offered a menu.

Events

DirectionNameConstPayload
inpoker.actionRequiredPokerAIRandyInputEvents.ACTION_REQUIRED{ playerId, actions, context? }
outpoker.turnActionPokerAIRandyEvents.TURN_ACTION{ playerId, action }

poker.turnAction is the same name PokerBetting accepts as a human's raw action, so the director applies Randy's pick exactly as it would a HUD click — and exactly as it applies the default PokerAI brain's pick.

Dependencies

  • PokerBetting — supplies ActionType, NpcStrategy, and NpcContext, the action vocabulary and callback shape Randy fits.
  • PokerAI — supplies shortHand and classifyStartingHand for the HUD reasoning label the System writes onto the context.
  • PokerHandEval — the shared evaluator PokerAI's label helpers read; pulled in transitively through PokerAI.

Notes

  • One Randy table per scene: the System routes a menu into the first entity carrying a PokerAIRandyComponent.
  • The pick ignores the context entirely. The label the System writes ({ hand, tier, notes }) is for display only and never feeds the decision; pass a fresh context per turn if a HUD reads it back.
  • The injected rng is the one source of randomness. Pin it in a test (system.rng = () => 0 picks the first action) or seed it from a host for a reproducible session; it defaults to Math.random.
  • randyDecision([]) returns 'fold', but the System drops an empty menu before it gets there, so a seat never emits an action it can't take.

More like this

PokerAI
PokerBetting
PokerHandEval
AIGoalSeek
AIKick
AIZone
AiPilot
BallPossession
BallPursuit
CardFan
DeckDealer
Enemy
EnemySpawner
FreighterChain
LineOfSight
PokerAIBill
PokerAICali
PokerAIShark
PokerAISurge
PokerAITilt
PokerHUD
PokerInput
PokerMultiplayer
PokerSeating
PokerTableCards
PokerTableDirector
TurnPacer
WaveDirector

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search