Inspiration

We wanted to build a poker bot that makes smart choices using math, not luck. The game in this challenge is hard: each player gets 5 cards, the deck has only 36 cards, and you must use exactly 2 of your cards with 3 cards from the table. The rules for the bot are also strict. It only gets 8 seconds of thinking time for 1,000 hands, and if it crashes 5 times, it loses the whole match. So our goal was simple: play smart, and never break the rules.

What it does

Every time it is our turn, the bot compares two numbers:

  • Chance to win: how often our hand would win if both players showed their cards.
  • Price to play: how much of the final pot we have to pay to keep playing. For example, if we must pay 10 chips to win a pot of 30, we need to win more than 25% of the time.
  • If our chance to win is high, the bot raises.
  • If our chance to win is higher than the price, it calls.
  • Otherwise, it folds.
  • The bot also watches how its opponent plays. If the opponent raises all the time, the bot does not get scared. If the opponent rarely raises, the bot takes the raise seriously. If the opponent folds a lot, the bot bluffs more. If the opponent never folds, the bot stops bluffing.

How we built it

  • Fast hand scoring: Before the game starts, the bot builds a big lookup table with the score of every possible hand, using the official scoring code. Checking a hand then takes about 30 times less time, so the bot can test many more situations.
  • Simulation after the first cards are shown: The bot plays out 40 to 400 random versions of the rest of the hand to estimate its chance to win.
  • A formula for the starting hand: We simulated every type of starting hand (about 20000 types, 2000 games each). Then we found a simple formula that predicts how strong a starting hand is, with only about 1.5% error.
  • Time control: The bot plans how much time it can spend on each decision, so it never runs out of its 8 seconds.
  • Safety: If anything goes wrong in the code, the bot safely checks or calls instead of crashing. We used Python and NumPy inside the web server given by the organizers, and we tested the bot with the official Docker build check.

Challenges we ran into

  • Speed: The provided scoring code was too slow to test many hands. We solved this with the lookup table.
  • Time limit: On our laptop, even a bot that does nothing used most of its 8 seconds because of network overhead. We measured the real cost in a Linux container (about 2.6 seconds per 1,000 hands) and added time planning to stay safe.
  • Testing like the real tournament: One local test failed in a strange way. We learned to test each half of the match on a fresh server, the same way the tournament does.
  • Start-up time: The bot must be ready within 15 seconds. Building the lookup table takes only 1 to 2 seconds.

Accomplishments that we're proud of

  • The bot won all 4 test matches against the provided bots, by a large margin, with no crashes.
  • Our fast scoring matches the official scoring exactly. We checked it on thousands of random hands.
  • It passed the official build check and all the provided tests.

What we learned

  • In this format, two bots of similar skill usually tie. To win a match, you need a clear lead, so beating weaker bots by a lot matters most.
  • A simple bot that never crashes is better than a clever bot that sometimes breaks.
  • Poker results are noisy, so you have to test with many games before you trust a change.

What's next for YAK

  • Let the bot play against different versions of itself to find better settings.
  • Play differently depending on table position.
  • Learn from the cards opponents show at the end of a hand.

Built With

Share this project:

Updates

Submission history