Since this series began, I’ve been asked one question over and over.
How do I build a poker bot for Poker Stars and/or Full Tilt? How do I extract text from the game chat window? How do I snoop on hand history and log files as they’re generated?
Today we’re going to answer that question.
As of this writing, Poker Stars is the most popular poker venue not only in the world, but in the history of poker. Online or brick-and-mortar, it doesn’t matter. There’s not currently, and there never has been, another card room in which so many people congregate so routinely to play poker for such sums of money. If you took one of the largest buildings in the world—for example, the Lockheed-Martin manufacturing plant in Fort Worth, Texas…
…and filled it with tables, stretching off into the distance, you’d have yourself a casino which could handle maybe 1% of Poker Stars traffic. Maybe 5% if you pack them like sardines.
With well over 120,000 players at peak hours, Poker Stars isn’t really a card room at all.
It’s a small city.
Controlled by a mysterious group of investors, operating behind the veil of privacy.
Nothing wrong with privacy; given the politics surrounding online poker, I positively understand it. But in the absence of hard information, rumors abound: Poker Stars is owned by a group of top poker players; a cadre of eccentric billionaires; foreign governments; you name it. I challenge anyone reading this (other than Poker Stars staff and other industry insiders) to answer the question:
Who owns Poker Stars? Who owns Rational Entertainment Enterprises, Ltd.?
Because that’s a tough nut to crack, when you’re on the outside looking in. And inquiring minds want to know.
Building a Monitor Bot for Poker Stars and Full Tilt
Anyway, we’re going to build a little application which is capable of extracting complete table and game information from the Poker Stars client. Hole cards, board cards, player actions, you name it.
We’ll call it the “MonitorBot” although it’s not technically a bot since this one (unlike last week’s FoldBot) doesn’t actually click any buttons. Here’s what it looks like. Nothing too snazzy as you can see…
Did I mention that one thing today’s bot will not do, is click any buttons on your behalf? It’s only purpose is to gather information. Because it doesn’t automate your play, use of this tool does not constitute a violation of typical online poker EULAs. In fact, all of the information retrieved by this tool can be extracted by publically available tools such as Spy++ and others.
But notice that we’re displaying game chat text (in real time) in the top right window, and notice that we’re displaying log file text (in real time) in the middle window. Getting access to this text cleanly can be a little tricky.
Several techniques are demonstrated in today’s article. I’ve broken these out into separate posts.
- How I Built a Working Online Poker Bot, Part 6: Guerilla-Style File Monitoring on Windows with C# and C++ explains how to snoop on poker client hand history and log files as they’re generated, in real time. We’ll build a simple file monitor application that can be pointed at any poker client (or any other application) to get a real-time view not only of the files it’s creating and opening, but the data it’s writing to and reading from those files. And we’ll introduce C# into the botting series for the first time.
- How I Built a Working Online Poker Bot, Part 7: Extracting Text from 3rd-Party Applications describes how to snoop on text drawn by external, 3rd-party applications. It also demonstrates a few GDI “parlor tricks” you may not have seen before.
Then in Part 8 (coming sooner than you think) we’ll take these techniques in a direction you might not have anticipated. It should be interesting. Stay tuned.
Running the Poker Stars MonitorBot
In order to run the above application, you’ll need to do two things:
- Download and build the source code (and this time, no Boost libraries! And no NMAKE!)
- Download and install Poker Stars (www.pokerstars.com) and/or Full Tilt (www.fulltiltpoker.com) and set up a play-money account.
Once you’ve downloaded and installed Poker Stars, you’ll need to set your dealer message verbosity to “Everything” as shown here:
Repeat the above step on Full Tilt. Then follow these steps to see the MonitorBot in action:
- Launch the Monitor Bot executable (XPokerBot.EXE).
- Click the “Launch Poker Client” button and browse to the location of the main Poker Stars executable. On most systems, this will be in C:Program FilesPokerStarsPokerStars.exe. Alternately, browse to Full Tilt.
- You should see the Poker Stars client launch. Messages will start to appear in the MonitorBot user interface.
- Open one or more Poker Stars game tables. If the tables don’t appear in the MonitorBot UI, jiggle the table window by bringing the MonitorBot UI to the foreground, and then bringing the poker table window to the foreground, etc. This is due to a quirk in the underlying Window detection logic.
- (Optionally) open the Full Tilt client (FULLTILTPOKER.EXE) using the same “Launch Poker Client” button, and open some Full Tilt tables.
The MonitorBot is a demonstrative application, not a working poker bot. As a result:
- It only works with Texas Hold’em tables on Poker Stars, Full Tilt, and Poker Time.
- It only works with Windows XP. It may or may not work on Windows Vista.
- MonitorBot doesn’t display hole cards in the UI like the FoldBot did. Instead it demonstrates how to pluck these cards from the log file and/or game text windows.
It’s intended to show you techniques which you can use in your own applications, or to serve as a “starter kit” which you can embellish.
Hey! Where are the hole cards?
Different online poker clients emit different information into the game chat window. Some of them, such as Poker Time, display your hole cards in this window; others, like Poker Stars, don’t. But in that case they may emit hole cards into the log file (as on Poker Stars) or into the hand history file (as on most poker clients, although there are timing issues).
And in any case, there are other ways to go about getting the hole cards. The point of today’s post is to show you one way (out of several) to access the three basic types of text emitted by the client…
- Game chat window text.
- Log file text.
- Hand history text.
Once you have access to that text, what you do with it is up to you.
Building the Source Code
This week’s project is much easier to build than the FoldBot we looked at last week.
- No more Boost! By popular demand, clean regular expressions are gone in favor of low-level, error-prone, but considerably easier-to-build string manipulations.
- No more NMAKE! This project uses the Detours library, but I’ve included separate Visual Studio projects for detours.dll and the Detours marker DLL.
So what are you waiting for? Download the MonitorBot source code (C++/Windows 157KB).
Conclusion—Where’s the AI?
As interesting as inter-application command and control techniques can be, I think you’ll find the A.I. aspects of bot-building even more interesting. We’ve been busy laying out the framework for the bot’s eyes (input) and hands (output) but we’ll return to the A.I—the brain—before too long.
For those of you who are new to poker botting, we’ll discuss how to build an A.I. from scratch, and we’ll talk about how to leverage existing commercial bots as programmatically callable components inside your “master” bot. And whether you’re new to poker botting or not, we’ll discuss hand evaluation and comparison, game theory and the nuts and bolts of ICM calculation, rules-based vs. heuristic approaches, the importance of table selection, and much more. And at some point we’ll say hello to some of the other communities and poker-programming sites that are out there, commercial or otherwise.
Until then, good luck in your poker and programming endeavors.