Authors: Harlan, Ben
What is the problem?
Playing poker well requires the ability to quickly determine what hands you and your opponents can make - as cards are being dealt. Knowing who has the mathematical advantage at any given stage of a poker game can be a serious leg up. We are going to develop a poker assistant that will tell players this information rapidly, while they are playing a game. Not only will this improve a player's odds in situations where they can use external help (online games), but it will help them develop their ability to come up with the information on their own.
What is the something extra?
We will include some minor natural language processing so that the user can easily describe the state of the game to the interpreter in plain english. As well as providing statistics about a player's chances at a given stage in a game, we will also recommend that the player bluff or not bluff in accordance with the spread of possible hands.
What did we learn from doing this?
Working on this project re-affirmed our appreciation of Prolog's pattern-matching power. Our domain was particularly well-suited to pattern-matching. We were able to write predicates to determine whether a set of cards corresponded to a particular poker hand in very few lines of code.
When trying to generate the best hands for a player's set of cards, we started off by generating all possible hands, and then searching through those hands to find the highest ranked. This approach led to some serious time-complexity issues. Asking the assistant for statistics even when just playing against one player took an impractical amount of time. We adjusted our approach to look for the hands in order of their rank, and to search for each individual hand in an order that takes into account the hierarchy of similar hands (two straights for example) - this resulted in drastic speed-ups.
The poker assistant is now able to, given your pocket cards, and a set of cards currently on the table, determine the probability with which you will win the round.