Archives

A Scriptable Equity Calculator

For all of your programming poker players out there, yesterday I made the Poker Sleuth Equity Calculator scriptable with bindings for C/C++, C#, and Python.

If you have easy_install or pip set up for Python, you can just do “easy_install pokersleuth”. It requires a 32-bit version of Python for Windows.

As an example, to compute the odds of winning when you have a pair of Jacks, your opponent has the Ace and 5 of diamonds, and the board cards are the 3 of diamonds, 5 of clubs, and 9 of diamonds:

>>> import pokersleuth
>>> pokersleuth.calculate_equity('3d5c9d', ('JJ', 'Ad5d')
[0.48225, 0.51775]

Share

DefaultValue Attribute as Initial Value

Visual Studio Properties

C# lets the programming define a default value on a class property, so that GUI widgets can test the property to see if it still has the default value. Visual Studio, for example, bolds any properties that have a non-default value, making them easy to pick out.

Unfortunately, the default value isn't used to actually initialize the property. The initialization must be done elsewhere in the code, typically in the class's constructor. Having to type the same value in two separate places in the code is error-prone, since it's easy to inadvertently change the value in one place and forget to change it in the other.

How to debug a program

Cicada

Debugging is a fundamental programming skill. It's also one of the least fun and least glamorous tasks a programmer faces. In order to reduce time spent debugging, I've invested time in examining my debugging methods. Below, I've documented the techniques that most reliably lead me to a solved problem.

I'll avoid getting into the gritty details of particular tools and instead stick to basic principles that can be applied in almost any situation.