# How to get started building a poker bot?

I've been learning programming as a hobby for a few years and have a basic understanding of Python, C++, and javascript. I'd like to tackle a new project of programming my own NLHE poker bot.

I understand this is a HUGE project to tackle, but are there any resources or open source libraries you'd recommend?

I've seen OpenHoldem used to be a good one, but it doesn't look like it's been touched in a couple years.

I suggest you write an equity calculator first as a bot needs one. If you base stuff off equity it is so much easier. Then just a binary made or draw hand.

Then you can just do an odds for call and give a fixed implied odds on a draw. If you need 3:1 to call on a draw go with one less 2:1. All you have left is bet sizing for open and re-raise. Bluffs is a little harder but if you just bluff your busted draws like 1/3 you will be pretty close.

Call bluffs is a little harder but you are going to get some stats on how often they bluff when you just call for equity. Call back about 1/3 of their bluff rate if you have a bluff catcher.

Assign an open range for each position and bet sizing. Flop sizing like 1/5 is enough to throw them off.

I tried a GTO based bot but it was a disaster. GTO you are playing not to lose.

Based on play you can adjust range of the opponents. If you base logic on equity then you don't need complex rules.

According to a new post this can be done with machine learning.

• That's more or less what I'm planning on doing. Just hoping there's a good library out there that already has OCR and odds/equity calculations. Trying to start as far ahead as possible. – mdrichardson Jul 28 '17 at 19:33
• Then good luck to you – paparazzo Jul 28 '17 at 19:37

It's something I considered and started a few years back but gave up on.

Look into Tesseract OCR. This will be the "eyes" of your bot.

Next have a firm understanding of the poker variant you want the bot to play.

Next look into machine learning e.g. classification such as with neural networks (and also feature extraction / dimensionality reduction to get the most relevant statistics)

Finally don't bother. It's already being worked on (look up Doug Polk's video). Pokerstars has anti-bot technology so you'll need to develop a very advanced AI capable of passing the turing test for that site, and sites that allow bots will have bots that will crush your bot. Also, by the time you finish development online poker could have been destroyed by advanced bots already!

If you are REALLY keen then you could familiarise yourself with github. A Google search brought up a poker bot being developed on github which you could contribute towards or at the very least get some ideas from.

• Could you provide some example features. – paparazzo Aug 2 '17 at 15:26
• I only got as far as reading information from up to four tables and keeping track of the game state e.g. who's turn it was to act, where was the button, etc. – user4555 Aug 2 '17 at 22:40
• How do you deal with equity as a feature? – paparazzo Aug 2 '17 at 22:55
• Well one approach could be to use machine learning and train with hand histories (a lot of them!). Your classifications (the bots decision) would be fold, call/check and raise. This approach isn't great because it assumes fixed raise and call sizes. You could refine further though and have classifications for half pot bets and full pot bets, etc. You want the bot to pick the classification that has the highest EV as defined in the hand histories, but also the closest action in the present moment to the hand history. – user4555 Aug 2 '17 at 23:06
• Thanks for the insight! As for the "don't bother" part, I think I'm going to respectfully ignore it. My intent to build it wouldn't necessarily be to use it in real money play as much as just to build up my programming skills. Since I'm kind of new to poker, I think it would be fun to have it suggest actions based off of GTO, rather than play 15 tables for me. – mdrichardson Aug 3 '17 at 17:22

First of all, explore projects on GitHub. There you may find a many examples of already work code. The second, you must understand that "Poker Bot" is a multicomponent task, wich consist from basic parts of similar programs - main loop, game logic, GUI, data(storage, conception, processing), API, external code, and so on.

Especially, is implement API to work with external code such as "PokerTracker". The similar programs is in the root of background data. Also, meta-data is a screen image of what is happening on game table. This type of information must be obtained and processed for a constant time!!!

Solutions obtained during the implementation of artificial intelligence should be applied by actions on the game-table on monitor.

In my opinion, the algorithm that should be used in PokerBot must create a tree of solutions, algorithm of round and sort such as MiniMax, and algorithm of relational storage such as NestedSets.

Discussion of the technologies that should be used in this project is the subject of a separate conversation :)