Monday, October 5, 2009

IronPython Texas Holdem Poker Spreadsheet and other .NET Poker applications

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.

Shortly after the INETA contest, I found a Silverlight contest sponsored by Telerik. Since I learned IronPython in the Resolver One contest I figured that this was a great excuse to spend a week or two learning Silverlight, WPF, and XAML. While I didn’t end up winning the contest, I did get a license for their Silverlight controls and was able to create a pretty cool Silverlight 3.0 Texas Holdem Monte Carlo simulator that runs entirely in the browser. I also organized all the source code and various versions of the application into one website for all your Poker needs.

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.

Texas Holdem Spreadsheet

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

Enjoy!

10 comments:

Greg Bray said...

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!

Herschel said...

Good job on the Silverlight version. It was working earlier today, but seems to have stopped (Silverlight version).

xeromidas said...

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

Greg Bray said...

The Silverlight version seems to be working for me, but it is still only part way done as it doesn't show results for suited cards yet.

I started looking at using equity instead of win/tie/loss stats, but only got as far as the basic method for calculating the equity for a single trial. More info here: http://codeblog.theg2.net/2009/11/texas-holdem-hand-equity-calculation-in.html

Dendy said...

Thanks for sharing

William Hill said...

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.

Caitlin at Buy Backlinks said...

Brilliant! Been looking around for something like this. Wonderful that I can run it in a browser.

David S.Y. Wong said...

Check out the free Texas Holdem Windows Program for learning and practice.

Betty @ Wholesale Handbags said...

Thanks. Now I can analyze and simulate hands and maybe make me a better poker player.

Agung Darmawan said...

great information, i like it. busana gamis jeans | gamis & Hijab modern terbaru

Post a Comment