It’s definitely been longer than I intended since my last update, but I’m going to be putting up my next update in the next day or so to try and make up for that mistake. The first update will be this one, talking about the AI I’ve implemented, and a number of other changes which have improved the game as a whole. The second update will be a character update and will talk entirely about the characters in the game. That update will have more information about the characters themselves, and who they are. Without further ado, here’s how the game’s looking:
If you looked at the last update, the game should look pretty similar to what it was before. Sadly I didn’t get to do too many visual improvements since the last version. I’ve made a few small changes to the colors in the UI in certain places, but the general look of the game is basically the same. Most of the UI changes are more obvious during specific moments within the game.
The first change I made was related to the high card deal that occurs at the beginning of the game. I was having a lot of trouble telling who had won the high card deal so I decided to make it more obvious by highlighting the character who has the high-card, and creating a text object above them that says “High Card”. This occurs for the winner, and also highlights every player involved in a tie if multiple players have the same high card. I also turned off the system that automatically starts the game after the high card has been determined, and gave the player the ability to choose when the game would start. These two changes together were a substantial improvement and made the whole high card process much clearer. Below you can see an image of what the player looks like when they have the high card, and what a tie looks like.
The next UI improvement I made was related to the alert system I developed for the last update. Previously the alerts would disappear after a certain amount of time. This meant that if the player got distracted, or wasn’t paying close attention, they might miss what action the opponent took, and not know what was going on when they went to take their move. To prevent this issue, I made it so that the alerts stick around until the end of a round of betting, or until they are no longer valid. So if a player raises, all of the Called and Checked alerts disappear, but none of the Folded, and Out alerts disappear until the round has ended. Below you can see what the current alerts look like.
You can also watch this gif to see the alerts in action, and what happens when a player raises.
I also wanted to make re-raises clearer to the player. In a real game of Texas Hold’em, it’s not uncommon for multiple players to raise in the same round of betting, or for one player to re-raise another to try and force them out. With my previous system, only the most recent raise would be visible, so if the player looked away or got distracted, they may not know how the Pot got from where it was before to where it is now. To solve this problem, I made it so that when a re-raise occurs all of the existing raises get “demoted” and are moved physically downward out of the alert area, and grayed-out. This shows they are not the current raise, but are still relevant. This allows the player to step away from the game for a minute and come back still come back in without any confusion.
The final small change I made to the alerts was the Winner alert that pops up at the end of a round to show who won. Previously this screen only showed who the winner was, but didn’t say how much they had won. I fixed this so that the win screen would a bit more informative, and below you can see what it looks like. Eventually I’m going to make it so that the win screen will also highlight what cards that were used in the winning hand, or say what type of hand the winner used.
I also added a Pause screen to the game for obvious reasons. Right now it doesn’t have any options, but I thought I should add it in now and get it out of the way. You can see what it looks like below.
By far the biggest things I added to the game for this update were the AI improvements. In previous versions of the game the AI was very simple and would basically just call in all scenarios. Obviously this didn’t make for a very interesting game. I finally set about solving this by implementing the AI I had been planning. With this update I implemented what I’m referring to as the first draft of the AI that’s used on the initial deal, before the flop is dealt, and I created an accurate system for Out detection. To gain a better understanding of exactly what I did with this update there are a couple poker concepts/strategies you should know about.
The first concept I implemented is referred to as the Chen Formula. The Chen Formula is a simple formula that a poker player can use to determine whether the hand they’ve been dealt is really worth playing and betting on. Below you can see the Chen formula rules. Take the highest card in your hand and use these rules to determine your hand’s score:
- Ace = 10 points
- King = 8 points
- Queen = 7 points
- Jack = 6 points
- 10 through 2 = half of face value (i.e. 10 = 5, 9 = 4.5)
- Pairs, multiply score by 2 (i.e. KK = 16), minimum score for a pair is 5 (so pairs of 2 through 4 get a 5 score)
- Suited cards, add two points to highest card score
- Connectors add 1 point (i.e. KQ)
- One gap, subtract 1 point (i.e. T8)
- Two gap, subtract 2 points (i.e. AJ)
- Three gap, subtract 4 points (i.e. J7)
- Four or more gap, subtract 5 points (i.e. A4)
The examples used here come from SimplyHoldem.com
Once you have the score for your hand you can then determine whether a hand is worth playing by looking at your position in play(how early or late in the betting are you), and the actions of the previous betters. The later you are in the play, the lower a Chen value you can risk going in with. With this update I not only gave players the ability to check what their position in play is, I also gave them the ability to calculate their Chen value. Then, I took the standard betting principles/rules with the Chen formula and modified them based on the style or skill-level I wanted to model a given character after. So a fairly good player is going to consider their position and their Chen value when deciding whether to play. Less skilled players place more value on things like having a pair, even if it’s not a great one, having a high card, even if it’s not connected to or the same suit as your other card, and even use a flawed form of Chen evaluation. The really poor players also don’t consider their position since that’s something most players don’t do when they first start out.
By combining the basic principles of the Chen formula and thinking back to how I and my friends played when we weren’t as good, I was able build AI that could represent the different players in different ways. While I’m still tweaking how each player reacts, and what Chen values they will go in on, I have at least a good starting place for each of their pre-flop AIs. Below you can see a gif of a few different deals and how the players don’t always behave the same way. Right now Bernard and Yuri have particularly conservative play patterns so sadly they didn’t come in on any of these games, but you can still see pretty varied behavior among the other three non-player characters Roxy, Turbo, and Tom.
The other major AI system I implemented is the ability for a player to determine how many Outs they have. In Hold’em, an Out is a single card which could be dealt that would make your hand the winning hand. Here’s an example: If you have an Ace of Diamonds, and a 9 of Clubs, and the flop is a 5 of Hearts, 7 of Diamonds, and King of Diamonds, then you could have the winning hand by getting any of the remaining Aces. That means you have three outs, since there are four total Aces in the deck and you have one of them. Your hand could become better by getting a 9 as well, but those wouldn’t be Outs because you have to assume one of the other players has the King-pair and that would beat your 9. You also have 10 more potential Outs from the 10 remaining Diamonds in the deck which could give you a Flush. The problem with these Outs is that you’d need two Diamonds to make the flush, so no individual diamond could give you the winning hand at this point. Some people would consider those Half-Outs, but it’s a matter of opinion whether they should be considered.
This was a particularly challenging thing implement because of the difference in the way computers process information and how humans do. Thankfully, after some hard work I was able to make an accurate system to count how many Outs a player has. While I haven’t taken this system to the next step and started using it when determining actions and potential moves, I am well on my way to having the AI for post-flop play implemented.
Back-End and Debug Systems
Along with all the user and gameplay-centric updates I did, I also went through some of my old code and improved a number of things. I even eliminated a small memory leak I noticed. Doing this not only made the game function more smoothly, it also allowed me to create a debug mode where I can change the cards player have at will. Previously, because of the way the cards were handled, I couldn’t easily change the cards mid-game and testing certain scenarios was a huge pain. With the improvements I made to this version I was then able to make a very simple menu which I can use to change a card at any time and see the results almost immediately. At one point I was trying to track down an issue related to the way Straights are detected, and without this new menu and debug system in place it would have been a gigantic pain to find and resolve.
The final thing I want to mention in this update is the art progress. Sadly the art has not progressed much. While I’d like to think I’m an okay artist, character art is not really my specialty. With this in mind I decided it was better to simply contract out the character art and move forward with the parts of the game I am good at. I reached out to a friend who is an artist and we came to an initial agreement about me contracting her for art duties. While I’m still in the process of sending her information regarding what I’ll need for each character, what sort of style I want, etc, I should have the first sample image before the next update after the initial Character one. From there I can take the next step and either actually contract her, or start looking for another artist. I still plan on doing the environment and UI art if I can, but I will have to see where the game takes me and whether it is feasible as I get closer to finishing certain parts. Likely whoever I end up hiring to do the character art will do basic layouts for the environments and give input on the UI, but I’m still not sure whether I will ask them to do the full art for that as well.
Stay tuned for my other update this week, which will give all the details on the poker players available in the game.