Introduction
I’ve been in the mood to create a Texas Hold’em game, and I’ve been thinking about how to design it, but the rules of Texas Hold’em are surprisingly complicated. Also, I feel that giving players too much freedom, like in a real game (being able to decide the number of chips for a raise) can slow down the tempo of operation. Make a quick note of what we need to think about.
As for what kind of game I would like to make, I think it would be something like:
- Starting with a set initial amount of chips, players aim to gain as many chips as possible by stealing chips from opponent players (NPCs). If an opponent player loses more than a certain amount of chips, he or she will leave the seat and another opponent player will appear.
- The more chips you acquire, the stronger opponents (who have more chips) will appear in your seat. The number of chips you have represents the user’s level.
- Record the maximum chips you have won and aim to maximize this value. If an opponent that you cannot beat appears, you will lose your chips and the game will end, so you can check the strength of your play by this maximum value.
- As a bonus, it will have cheating features (such as making the winning probability of your hand visible, or making information about the opposing player’s personality visible).
I will discuss the main concern, designing opponent players (NPCs) (how to create strong (or weak) AI) in elsewhere, but I would like to list the elements that must be taken into consideration when designing a game.
State Variables and Rules in Tables
The state variables outside of Texas Hold’em play (at the table) are:
- Number of players seated.
- The number of chips each player has.
- Blinds (minimum bet amount).
- Player seating order (order of turning the dealer button).
- The player with the dealer button on the next play.
It would be fine if we just stored this information as data, but let us think about what we need to take into consideration when designing a game. Let us assume that this is a single-player game, and that all other players are NPCs.
First, the number of players seated will be made fixed/float as a game setting from the start. In the case of a fixed number of NPCs, the user will specify the number of NPCs. In the case of a fixed number of NPCs, it would be best to have the next NPC arrive immediately after the NPC that left. If the number of NPCs is variable, players will enter and exit randomly so that the number of players is between 2 and 10, but it would be better to model it so that players leave and sit down according to an exponential distribution. The conditions for an NPC to leave can be set as appropriate, such as the probability of the NPC leaving increasing in proportion to the number of times the game is played, or when the number of chips the NPC holds falls to half or less of the number of chips the user holds. This is because, due to the nature of the game, if there is a disparity in the number of chips, the player with the more chips will have too great an advantage. It would be best to have newly entering NPCs carry about the same number of chips as the user has.
The number of chips paid by the big blind is the minimum bet, but it is best to increase this amount appropriately to around 1% of the user’s chips. It seems like if plyers continue to play with a small amount of money it just takes time. The order of players’ seats and the dealer button could be managed by numbers (ID). If a new NPC is added to replace an NPC that is leaving, it may be a good idea to decide on a rule such as adding the NPC in front of the player holding the dealer button (the position where the dealer button comes around last).
State Variables and Rules during Play
The state variables during Texas Hold’em play are:
- Hole Cards and Community Cards dealt to players.
- Current betting round (Pre-flop, Flop, Turn, River, Showdown).
- The ID of the player who will be the starting point for betting.
- The ID of the player who will make the next decision.
- The number of chips a player puts into the pot.
- The state of the player (perhaps something like Live, Fold, All-in).
- Minimum raise quantity.
The starting point for decision-making is the player to the left of the big blind (after the flop, the small blind), but in the event of a raise, this changes to the player who made the raise. Once all the players before the starting player have made their decisions and the remaining players have put in the same number of chips, the next betting round will begin (in the next betting round, the starting player will return to the small blind). There is nothing else worth mentioning; all we need to do is manage these, but the question becomes how to design user operations.
Basically, the user has three options: raise (bet), call (check), or fold. An all-in would automatically go all-in if the result of a raise exceeds the chips you have, or if you call with a bet that exceeds the chips you have. Of these, the more troublesome operation is raising (betting). A raise can essentially be any amount you want, as long as it exceeds the minimum raise amount. However, making this optional would require users to enter quantities into text boxes, which is an undesirable operation both operationally and programming-wise.
Since this is a game after all, one solution would be to restrict the user’s actions a bit more, limiting the raise amounts that can be selected in a select box. When it comes to betting, the minimum amount is the number of big blinds, so you would simply specify how many times that number you want to bet. For raises, you are asked to specify how many times the current bet you want to raise. If players only use x1 (minimum raise), x2 and x3, it might be a good idea to have three raise buttons. Of course, this method cannot accommodate operations such as suddenly increasing the bet amount pre-flop, so the select box may still be more practical. Should I prepare x1 to x10? Or, the players are probably only use x1, x2, and x3…
Post-play Rules
After one play is completed, we return to the state of the second section, but we must distribute the chips accumulated in the pot. In real casinos, in Texas Hold’em, a commission of about 2.5 to 10% of the chips put into the pot is taken as the casino’s venue fee (called rake; this is the house edge and serves as the casino’s operating costs). Therefore, it is important to note that this is a gamble with a return rate of around 90 to 97.5%. In theory, it is possible that the casino is making a profit while all the players are losing out, and this is probably often the case. The system in this regard is probably no different from other public gambling games. As a game, it would be fine to make this configurable, but since this is a game that does not need to take chips from users, it would be better to not consider fees for the time being.
Texas Hold’em is winner-take-all, so if there is only one winner, all of the chips in the pot go to that winner. If there are two or more winners, the chips are divided equally among them. If there are three winners, the remaining chips are distributed to the player in the small blind. The tricky case is when there is an all-in player. If the all-in player loses, the winner takes all, but if the all-in player wins, the rules are quite complicated. This is done by following the steps below.
- The winner can take all the chips from other all-in players who bet less than him/her, plus a number of chips from the other players equal to the number of chips he/she put in (this total is called the side pot).
- Regarding the chips remaining after step 1, the winner will be determined only by the players who have inserted more chips than the winning player, and the winning player will receive the chips.
- If there are multiple side pots, repeat steps 1 and 2.
To give a specific example, say player 1 is all-in with 50 chips, player 2 is all-in with 150 chips, and players 3 and 4 each put in 200 chips. In this case, if player 1 wins, he or she will receive 200 (50 x 4) chips. The remaining 450 chips are compared among all players except for Player 1. If player 3 or 4 wins, they can distribute the chips using the usual procedure. If Player 2 wins, he or she will receive 300 chips (100 x 3). In this case, the remaining 150 chips will be compared between players 3 and 4 and allocated to the winner. In this example, if the first winner is Player 2, he or she will receive 500 chips (200 + 300). The idea would be to split the side pots into 200, 300, and 150, with player 1 only being entitled to the first side pot and player 2 only up to the second side pot. It seems like it would be a pain to implement this process programmatically.
Once the chips have been distributed, the dealer button will be moved, and NPC players will be allowed to join and leave the game, and the game will return to the state of Section 2.
When the Enemy Player Doesn’t Think
Once we have implemented the rules up to this point, we can begin to get the game in shape. I wrote that I would think about the design of the opponent player (NPC) later, but it would be easy to implement an opponent player that acts in a set sequence without any thought. Specifically, this method involves making the system act passively in response to all user actions. In other words, this is a method of thinking about an opponent who only calls (checks) in every step and does not raise or fold. In this case, the bet amount means that the user can set it as they like, and as long as they properly assess the strength of their poker hands, they become the opposing player who can keep increasing their chips. He’s not the weakest opponent, but if you can’t beat him, it means you’re not properly calculating the probability of winning with your poker hand before you even start negotiating.
By the way, in online casinos, when playing Texas Hold’em with two players, this type of opponent player (dealer) is often implemented (of course, I have never tried it, and it is probably illegal to play from Japan). However, since players are required to pay a fee called an Ante for each play, and there is also a limit to the amount that can be raised, it appears that the game is designed in such a way that no matter how well one plays, the expected value cannot be made positive. The optimal strategy can be easily simulated on a computer, so if you try it, it may be relatively easy to confirm that the expected value is not positive. The game I want to develop is multiplayer, so if there is only one enemy player in this format, there might not be any point in having more than two enemy players.
Another situation is when the enemy player acts randomly. For example, we might consider an opposing player who will raise 15% of the time, call (check) 80% of the time, and fold 5% of the time and so on. In Texas Hold’em, players who repeatedly raise (bluff) without any reason are seen as unpleasant people, so if there is a player who is likely to raise without any reason, some people may end up losing unexpectedly. For now, I have implemented these specifications and made it possible to play the game. Please refer to the following page.
Comments