How a Game Engine Switches Rules Mid-Match

The table’s “lifetime” is defined by the table itself – the number of players, their stack sizes and seat locations. Each hand gets a lifetime which lasts from the moment the hand begins until the moment it ends. The table does not close during this time period – the hand simply operates with a specific set of rules and parameters (the pot size, the community cards etc.) which are applied throughout the course of the hand. When a hand completes, the engine determines the winner based upon the active ruleset, and pays out accordingly. The engine then updates the table’s “state” (i.e., each player’s chip stack) to reflect these payouts.

For example, if Player 1 has 200 chips remaining after the previous hand, that stack will carry over into the next hand. As soon as a new hand is created, the table’s “state” remains unchanged, but the new hand now has a new pot size, a new deal of cards and a fresh rule-set.

Although other rule sets may be available for future hands, the active rule set determines how cards are dealt, who acts first, and which actions are permitted. For example, Texas Hold’em begins with two face-down cards per player, while Seven-Card Stud begins with two face-down cards and one face-up card. The engine can use the same general instruction to initiate the opening deal, while the active rule set determines the number and visibility of the cards.

Update the Rotation After Each Completed Hand

You may store rotations (the order in which you play your games) as lists. A “position” within the list identifies where you are playing a specific game. A “count” represents how many times you have completed this game since the rotation began. Once the engine determines a hand is complete, the “count” will increase by one. At that point the engine will determine whether or not you need to advance to the next entry on the list. When you advance to the next entry, the “count” will reset back to zero. The next hand played will begin reading the new entry on the list.

When a hand completes and the rotation needs to advance, the engine should save both changes together. That way, if the server goes down after the hand ends but before the rotation is updated, it restarts with the correct rotation. There are multiple ways to implement this event; however, one method combines both events into a single database transaction. Upon restart, the table can pull the most recent rotation position from the database prior to beginning to deal again.

Here is a screenshot of Phenom Poker, showing a Limit Omaha round at a H.E.R.O.S. Mix table. This is one position in a given rotation. According to Phenom Poker’s published rules, six-seat cash tables play six hands of each game before switching to the next variant, even when the table is not full. In this implementation, the number of completed hands determines when to switch.

Send New Information to All Clients About What Games Are Being Played

The server can provide a unique ID associated with the newly dealt hand along with what game is now being played. With this information, the clients can update their display of which game is being played and use that information to retrieve whatever controls they need for that game. For example, once the game switches to Seven-Card Stud, each player’s bets and face-up cards appear in front of their seat, and the client clears the community cards from the previous hand. Similarly, each client should get rid of any community cards that were shown in the previous hand.

A new ID for every hand is important because it allows the server to recognize when an old action was sent while a new hand is already in process. Consider the case where a player has submitted a raise immediately before the previous hand ends. The server can compare the hand ID attached to the request with the ID of the hand currently in progress. If they differ, the request is out of date. If there are different names for each hand, it means that the request made earlier was out-of-date. By validating the hand ID and rejecting outdated requests, the server can prevent an action intended for a previous hand from being applied to a new one.

Test the Last Hand and the First Hand Together

  • Testing the transition between games. Automated testing may begin with a table near the end of a rotation. If a test mix consists of six hands of Hold’em followed by Stud, load five completed Hold’em hands. The next deal should still follow Hold’em rules. Once that hand is complete, the following hand should use Stud rules (two face-down cards and one face-up card per player). Testing both hands helps detect switches that occur too early or too late.
  • Testing duplicate events. Submit the same hand-completion event twice to verify that player stacks and the rotation counter are updated only once. One way to achieve this is to record the table ID and hand ID for each completed hand, allowing the engine to recognize and ignore duplicate events.
  • Testing the rotation boundary. When a rotation wraps around from its last game to its first, the engine should reset both the rotation position and the hand counter. A test at this boundary can verify that player stacks and seat assignments are preserved, while the pot, dealt cards, and legal actions are initialized for the new hand.
Scroll to Top