Monday, October 5, 2009

Earlier this year I created a Monte Carlo Texas Holdem Simulator using an IronPython powered spreadsheet in Resolver One. The main goals were to learn IronPython, test how well it worked for creating complex spreadsheets, and enter a few of those spreadsheets into the Resolver One competition. Well I can honestly say that I exceeded even my own expectations on all three accounts, and it didn’t stop there either. After learning IronPython I started using it for the occasional random “Hey could you ...” tasks that get assigned to me at work, and I found a few other interesting uses for Resolver One as well.

I also found that I really like coding contests! After the Resolver One competition ended, I came across another .NET coding contest sponsored by the International .NET Association (INETA) that was trying to promote reusable components from various vendors. I submitted Windows Form and Windows Mobile versions of the Texas Holdem hand evaluator, along with a short video clearly showing why my younger brother is a professional radio DJ and I am not :-P I didn’t have enough time to get everything that I wanted to into the new versions, but it was still enough to get an honorable mention and score a few free licenses for .NET components from the sponsors.

I have had a few people ask about how to modify the poker spreadsheet for different purposes, such as analyzing the outcome for specific hand groups or being able to include multiple hands in the player’s pocket card set. The original spreadsheet was designed to show the hands in a specific layout so it is not very easy to customize. Instead I made a new spreadsheet that uses a standard column layout and lets you enter hands using the Hand Query language that is integrated into the C# HandEvaluator library. This new spreadsheet lets you customize the opponent hands and allows you to define multiple hands for the player (ie: What would my odds be if I had AK offsuit or AQ offsuit?). It also lets you specify the number of trials to run for each Monte Carlo simulation and is smart enough to enumerate the cards if you specify more trials than it would take to go through all possible board cards.

If you want to try out the new poker spreadsheet you can download it from the Resolver Exchange. The free player license for Resolver One will let you open and run the spreadsheet, but you will need a commercial license or research license if you want to make any changes to the code. I would like to add multi-threading and a hand win type breakdown table, but there is another coding contest deadline coming up, so I have to work on another project for a little while :-P

10 comments:

Oh, and I forgot to mention that if you want to change the spreadsheet but have never used IronPython before, you should take a look at the http://www.trypython.org/ website. Michael Foord from Resolver Systems converted the standard python tutorial to run in Silverlight, so now the whole thing can be run directly in a browser. Pretty neat!

i liked a lot ur article. Am starting into this thing thing. I want to become a pro i hope soon, thats why am reading a lot, and also bulding a free poker bankroll, cause i dont want to risk anything yet. Gl and am looking foward for another article

I have been having tones of issues with the silverlight version.I think it because im on a mac, mac suck for anything poker related. I think the best course of actions might be to install parallels and run windows. Im going to give it a shot ill report back if it does not work.