How our poker bots think: Monte-Carlo equity
There's no magic formula for 'how good is this hand.' There's brute-force imagination — thousands of times a second.
Every decision a Wit's Games bot makes starts with one question: how likely am I to win this hand? That number is called equity, and there is no neat formula for it past the first couple of cards. So we do the next best thing — we imagine the hand playing out, thousands of times, and count.
Equity, defined
A hand's equity is its share of the pot if the hand were played to showdown many times over — essentially its win probability, counting ties as half. "72% equity" means: deal this exact spot out 100 times and you'd expect to win about 72. (Our odds calculator runs this exact engine — set any hands and board and watch it.)
Monte-Carlo: imagine, deal, score, repeat
We compute it by simulation. For each of thousands of rollouts:
- Take the deck of cards we can't see (52 minus our hand minus the board).
- Deal random hole cards to each phantom opponent and fill out the rest of the board.
- Score every hand, and tally whether we won, tied, or lost.
Average it all together and you have the equity. The more rollouts, the steadier the estimate — which is the literal sense in which our stronger bots "think harder": they run more simulations and so read close spots more accurately.
for (let it = 0; it < iterations; it++) {
// partial shuffle of the unseen deck, then deal the unknowns
const heroValue = evaluateBest(hole, completedBoard);
for each phantom opponent:
if (opponentBeatsHero) { lost = true; break; }
if (lost) losses++; else if (tied) ties++; else wins++;
}
equity = (wins + ties / 2) / iterations;Fast enough to feel instant
A naïve version would crawl. Two tricks keep it snappy: we only shuffle the slice of the deck we're about to deal (a partial Fisher–Yates), and we reuse the same scratch arrays every rollout instead of allocating fresh ones. The result runs synchronously between moves with no perceptible delay.
From a number to a decision
Equity is only the first input. The bot weighs it against the pot odds (the price to call), its position, and whether it holds a draw — then mixes in a bit of randomness so it can't be read off a single move. But it all begins here, with a bot quietly imagining the hand a thousand ways before it acts.