log

Implementing Blackjack and Poker

Notes on implementing two casino classics, Blackjack and No-Limit Texas Hold'em, on the Parlourite engine. The hard part was not writing the rules, but deciding where "one game" begins and ends.

We added two casino classics to the engine: Blackjack and No-Limit Texas Hold’em. Compared with the titles we have shipped so far, the rule definitions themselves are on the easy side. The wall we ran into was of a different kind, and worth writing down.

Board game rules are negotiable by nature

A single pack of cards, a single board, a single set of pieces can host many games. One box contains several ways to play, and communities keep inventing new ones. That openness is part of what makes board games what they are.

The same openness becomes a wall the moment you try to write a mathematically precise, machine-executable definition. A strict engine does not tolerate exceptions, and it keeps asking: where does the game end and the house custom begin?

Casino games look like they have fixed rules, but they are in fact one of the clearest examples of this drift. 6:5 versus 3:2 blackjack, S17 versus H17, whether double-after-split is allowed, late surrender, re-splitting aces. Every pit posts its own sign. Poker is worse: the procedural rules come from one authority, the structure (starting stack, blind schedule, level length) is decided per event, and only together do they describe a real match.

Is one hand enough?

Technically, a hand of blackjack closes cleanly. Deal, draw, dealer flips, settle. The game definition is complete.

But does a single hand feel like playing blackjack? The pleasure of tracking how the shoe tilts, bankroll management, the discipline of recalling the correct action for every dealer up-card — the things Thorp wrote about in Beat the Dealer and Wong refined in Professional Blackjack — none of them appear in a single hand. What is left is close to a negative-expectation coin flip.

Poker is the same, and more so. A hand of No-Limit Hold’em is a complete transaction: bet, fold, show, scoop. But the actual game lives in the sequence: reading an opponent’s history, managing your stack, folding at a loss because the future is worth more than the pot. A single hand cut from that sequence is poker by the rules and not poker by the experience.

So we settled on a principle. We define as “one game” the unit of play that most people would recognise as having played the game. This is not a statement about what the engine can express. It is a statement about what we want to put in front of a player.

Blackjack: what we picked

We based our rules on the six-deck Strip tables, leaning toward the competitive end of the spectrum.

  • Six decks, 312 cards per shoe; cut card at roughly 1.5 decks from the bottom
  • Dealer stands on soft 17 (S17)
  • Blackjack pays 3:2
  • Double on any two cards, including after a split (DAS)
  • Split up to four hands; aces split only once, one card each, and the hand ends
  • Insurance up to half the original bet, pays 2:1 on dealer blackjack
  • Late surrender; peek on A or 10-value up-card
  • One card burned after every shuffle; if the shoe runs out mid-hand, the discard tray is reshuffled back in and play continues

One hand is one round, and a match runs fifty hands. Left alone, a blackjack table can run thousands of hands before anyone busts out, so we capped the length to make a match a bounded experience. Betting order rotates one seat per hand, following the convention of tournament blackjack: later bettors see more, so moving the position around keeps things fair.

Solo play against the dealer is the default seating. It is the most ordinary blackjack experience in a casino. Multi-seat play uses the same definition without changes.

What we left out: 6:5 blackjack, which enthusiasts regard as a watered-down version of the real game; early surrender; continuous shuffle machines; side bets of all kinds. H17 will arrive later as a variant.

For verification we use OpenSpiel’s blackjack. Their implementation is a minimal variant — hit and stand only, no split, no double, no insurance. We started by trying to use it as a reference and quickly saw the scope was different. We flipped the role instead: we built a matching minimal variant on our side, and now the two sit side by side as a cross-check on the hit-and-stand core. Even over that narrow surface, agreement between two independent implementations is a useful foundation to build the fuller rules on top of.

Poker: what we picked

The target is No-Limit Texas Hold’em, single table, freezeout tournament.

We split the rules into two layers. The procedures — button and blind progression, minimum raise, showdown order, side pot resolution — follow the Tournament Directors Association (TDA) rules. The structure — starting stack, blind schedule, level length — is set per event, and here we tuned it to fit a single digital session at one table.

A few procedural points worth calling out:

  • Dead button. When a seat busts, the big blind advances to the next live seat and the button follows. The button can be left on an empty seat. Without this rule, a short stack can duck the blinds by timing a bust-out
  • Heads-up. Pre-flop the button (small blind) acts first; post-flop the big blind acts first. When three players collapse to two, the button is adjusted so no one pays the big blind twice in a row
  • Minimum raise is the size of the previous bet or raise. A short all-in that falls short of a full raise does not reopen action for players who have already acted — but if several short all-ins stack up to a full raise in total, action reopens from that point
  • Big blind ante is dead money; it does not count toward the call. Blinds are posted before the ante
  • Side pots are peeled off in layers by contribution. An odd chip goes to the first live seat left of the button
  • Showdown starts with the last aggressor; if the round ended on checks, it starts with the first live seat left of the button. When betting ends on an all-in, all hands must be shown
  • When multiple players bust on the same hand, finish order is decided by stack size at the start of that hand

Hand evaluation picks the best five cards out of seven. Once we add draw or stud variants later, this is a natural place to factor out. For now it is written specifically for Hold’em, and we will generalise when the second poker title arrives.

On structure we made one deliberate change. The headline tournament structure used internationally (300 BB starting stack, long levels) runs well past 300 hands to the end at a single table — ten hours live, far too long for one digital session. We kept the ratios of the blind progression but shortened the starting stack and the levels to fit a single-table session. The adjustment is marked in the definition as an intentional deviation from the source structure.

OpenSpiel plays a role here too. Their general poker implementation is designed as a one-hand betting engine parameterised by blinds and stack sizes, which is well suited to answering questions about per-hand mechanics: minimum raise, reopening, side pots. The tournament layer is outside its scope, so our cross-check works by slicing out a single hand from our implementation and running it against theirs.

What we left out: cash-game conventions (rebuys, add-ons, deal-making), limit and pot-limit betting, and other poker variants. Adding another poker will coincide with factoring out hand evaluation.

As a principle

For these two titles, engine expressiveness was never in doubt. The remaining shoe count and the cut card, aces split one-card-and-done, side pots peeled off in layers, the dead button rolling around a table with empty seats — all of this writes down declaratively.

The problem was simply this: a technically complete game definition does not always match what a player would call “having played the game”. Casino classics are where this gap is loudest.

So the principle we settled on is to define as “one game” the unit of play that most people would recognise as the thing itself. If we find a better place to draw the line, we will revise.