Posts Tagged poker

Pokerbot Lesson: Work Hard During the Good Times

As I mentioned in an earlier post, I wrote a poker bot in 2004.  I learned a lot from that project, and I’d like to share some of the lessons learned over a series of blog posts.

All poker players are familiar with the game’s swings.  Poker’s unpredictable sequence of wins and losses stems from the addictive cocktail of uncertainty and randomness that makes the game so popular.  There are many lessons to learn while riding the roller coaster of wins and losses, but I’ll focus on one that’s particular to a poker bot author (or an investor in the markets).

Imagine if you unleashed your poker bot algorithm and observed the following performance over the first 10,000 hands.

Pokerbot performance over 10,000 hands

Pokerbot performance over 10,000 hands

It takes a poker bot about 22 hours to play 10,000 hands.  This assumes that the bot plays 10 tables simultaneously, averaging 45 hands per hour at each table.  For comparison, it takes a human about 28 days to play 10,000 hands, assuming he plays an intense 30 hands an hour, 12 hours a day.  Although it’s not a large enough sample to yield a statistically significant win rate, it’s a sizable sample.

The first couple of times that this happened to me, I couldn’t help myself from leaning back and thinking that my troubles were over.  Instead of analyzing more data or writing more code, I’d relax.  Then I’d see this turn of fortune.

Fictional graph of big bets won or loss over time.

Fictional graph of big bets won or loss over time.

The downturn would give me a kick in the pants, and I’d dive in again to my work with vigor.

After this pattern happened a couple times, I realized how much time I was wasting.  Frustrated by this inefficient cycle, I made a point of staying vigilant even when the results looked promising.  I learned that you have to work hard even when everything’s going smoothly.

This lesson is applicable to both investing and software development.  When your PnL is positive, you need to make an extra effort to stay sharp.  When you’re writing software, you can’t assume that your program is correct just because it runs without throwing off errors.  Be suspicious and stay vigilant, even when things seem okay.

Comments (2)

My Pokerbot’s Architecture

Back in 2004, I spent most of my time building a poker bot to play low stakes limit texas holdem.  (A poker bot is a program that automatically plays poker against humans on one of the major internet poker sites).  The project consumed me.  It was both challenging and exciting.  I successfully ran the bot for a few years before shutting it down when I took my first job on Wall Street.

I worked alone on the poker bot.  I designed and implemented the poker client interface, the AI, and monitoring framework.  Since then, I’ve enjoyed reading a few blog posts detailing the efforts and celebrations of other poker bot creators.  Just today I read this one.  I’d like to join the party and share some details about how I built my bot.

PokerBotArchitecture

When I started the project, I wasn’t sure how to interface with the poker client.  The poker sites don’t provide an API, so I either had to reverse engineer the network protocol or build a screen scraper.  I knew a lot about hacking network protocols, and I had never built a screen scraper.  (I also noticed that one of the sites used an open source SSL library that I could swap out).

Despite these advantages, I wanted to build a screen scraper because:

  1. It’s harder for the poker client to detect a screen scraper.  I didn’t want exhibit an identifying communication fingerprint.
  2. I didn’t want to reverse engineer multiple network protocols.  It seemed easier to get a screen scraper working on different poker clients.

I wrote the scraper using C#.  One weakness of my scraper was that the windows all had to be a certain size, and they could not overlap.  I worked around this by building a simple tiling window manager with an AutoHotKey script.

I routed information from the scraper through a piece of software that I called the poker gateway.  This gateway directed information to a hand history database, poker AI, lobby AI, and control center.  All of these components ran on a separate linux box, and I used Ruby to develop them all.

This architecture was robust and flexible.  As a result, I could focus most of my energy and thought on building the AI.

I’d enjoy hearing from other poker bot creators.  It would be fun to swap war stories.

Leave a Comment

Follow

Get every new post delivered to your Inbox.