Exploding Coffee » Cygni Poker

The company Cygni recently held a Texas Hold'em tournament at Chalmers. And in true engineer spirit this was not played by the people who entered, but rather by bots created by the same.

Rules, server, etc can be found here.

They provided basic clients for several languages, primarily Java and Node.js but also one for C# which is what I went for. As I had to bring my bot to Chalmers for the tournament, and my laptop currently runs Lubuntu, Mono+MonoDevelop was used instead of my normal setup of Visual Studio and C#.NET.

HeuristicBot

I created a bot I initially called HeuristicBot, named such because it estimates the likelyhood of winning as a heuristic to make decisions from.

The method for doing this was quite simple:

  1. Create a list of available cards (one deck).
  2. Whenever a card is dealt to HeuristicBot or to the community (flop, turn and river), remove it from the list of available cards.
  3. When needed, repeat 500 times:
    1. Draw two cards randomly from the list of available cards.
    2. Compare the two cards (and any community cards) to our own hand (and any community cards).
  4. Count the number of times our hand was better.
  5. Divide by 500 and assume this approximates our probabilty of winning.

The full code is up on github, and specifically the bot implementation is here.

Once the estimate is computed the logic for taking actions is pretty simple, but rather long. In essence the bot is either cautious (probability >50% but ≤70%) and will then call up to a computed limit, or optimistic (probability >70%) and will then call and raise up to a larger computed limit. If the probability of winning is estimated to be below 50% the bot will refrain from playing.

See the link above to the source for the full implementation. I like to think the code isn't too bad but it was written during a single day so it's not my best work, so to speak.

Result

Initial results were quite promising, getting up to about a 80% win rate against the practice bots. During the actual tournament the bot (then named Hyperion) did rather well against the 14 other bots by staying in the middle for a while. It then held a stable third place until there were only three bots left.

At this point the bot had about a fifth of all chips and was doing well. Sadly the wifi on the laptop decided to disconnect here and the server did not support reconnecting.

I did still win third place and got two nice books for it; "The Clean Coder" by Robert C. Martin, and "Responsible Responsive Design" by Scott Jehl.

We did get a reveal of Cygni's next bot-game-project and they will apparently be back this fall, which should be fun.