BOOK 2 · PART II · BUILD · STUDENT CHAPTER
Your Why Becomes a Rule
Your hand journal is full of reasons. A robot is just a list of reasons written down so exactly that a computer can follow them. Take one line from your journal, turn it into one line of code, and send your first robot into Robot Wars. Then find out which of your reasons won't go.
Six lines
Open Robot Builder on HoldemRobots.AI and the box already holds a robot. Here it is, complete:
from fair_client import fold, call, raise_, PAIR
def my_bot(obs):
if obs.strength() >= PAIR:
return raise_()
return fold()
That's a whole poker player. Read it out loud and it's one sentence: if my hand is a pair or better, raise; otherwise, fold.
Now look at your journal. Somewhere on it you filled "I made a hand" and then raised. That's the same sentence. You've been writing robot rules since Part I; you just wrote them with circles instead of code.
Reading the robot, line by line
| LINE | IN PLAIN WORDS |
|---|---|
from fair_client import fold, call, raise_, PAIR | Bring in the three moves and the name for "a pair." raise_ has an underscore because raise is already a word in Python. |
def my_bot(obs): | This is the robot. Every time it's its turn, the table hands it obs, short for observation: everything it's allowed to see. |
if obs.strength() >= PAIR: | If my hand is a pair or better… |
return raise_() | …raise. |
return fold() | Otherwise, fold. |
Robot Builder's own note says what's in obs: "your two cards, the board, the pot, the price to call, position, whose turn." That list matters. It's everything your robot will ever know.
Which of your reasons can become a rule?
Go down the journal's reasons and ask one question of each: can I write it using only what's in obs?
| JOURNAL REASON | CAN A RULE HOLD IT? | WHAT THE ROBOT WOULD CHECK |
|---|---|---|
| Strong starting hand | Yes | Its two cards (the Complex example scores them) |
| Good position | Yes | obs.position |
| Cheap to see a flop · The price was right | Yes | obs.to_call against obs.pot (the Medium example does this) |
| I made a hand · Weak cards, let it go | Yes | obs.strength() |
| They bet big, scared me | Mostly | The size of this bet: obs.to_call against obs.pot |
| Drawing to something | Not yet | The examples read made hands, not draws. The Complex example says so: "chasing a draw on odds is the next lesson to add yourself." |
| I think they're weak · Setting a trap · Bluff · Gut | No | Nothing. These are about the other player's habits, and obs has no memory of what they did before. |
Look at the bottom row. Those are the reasons from "Read the Player, Set the Trap": the ones that beat the AI agent. Your robot can't use any of them, because every turn it starts from nothing, just like the bot you learned to beat. Hold onto that. It's the wall, and you'll meet it head-on two chapters from now.
Spot the leak in the sample
The six-line robot has a hole in it, and the poker refresher already told you what it is. When nobody has bet, checking is free. But this robot folds every hand weaker than a pair, even when it could check for nothing.
Fixing it takes one line. In Robot Builder's examples, call() with nothing to call is a check, and obs.to_call is the price to call:
from fair_client import fold, call, raise_, PAIR
def my_bot(obs):
if obs.strength() >= PAIR:
return raise_()
if obs.to_call == 0:
return call() # nothing to pay: check, never fold
return fold()
One reason ("never fold when you can check for free") became one line. That's the whole skill of this Part.
At the table
- Open Robot Builder. The six-line robot is already in the box.
Done when: you can read each line out loud in plain words. - Add the free-check line above, then click Save my bot.
Done when: the page saves without an error. - Pick one reason from your journal that a rule can hold. Write it as a sentence first ("if the price is cheap, call"), then as a line of code. Save again.
Done when: your robot has one rule that came from your own journal. - Go to Robot Wars and choose Use my bot. It plays the house bots.
Done when: the war has finished and you've written down the game number. - Run a second war with Use the sample bot, then compare the two in Game Review. Did your rule do what you meant it to?
Done when: you've found at least one hand where your rule made the move.
Try it yourself first
Turn each journal line into a sentence a robot could follow, and say whether obs can hold it.
- Cheap to see a flop → call.
- They bet big, scared me → fold.
- I think they're weak → bet the river.
ANSWER KEY
- Yes. "Before the flop, if the price to call is small compared with the pot, call." The robot checks
obs.street,obs.to_callandobs.pot. The Medium example works out the price asto_call / (pot + to_call). - Mostly. "If the bet is bigger than the pot, fold unless I have two pair or better." The robot can see the size of this bet. What it can't see is whether this player makes big bets as bluffs, which is what really scared you.
- No. "Weak" is a read on the player, built from what they did on earlier hands.
obsholds only this hand. A rule can't say it, because the robot has no memory to say it with.
Written by Kevin Swinson with Claudette, the pen name for Claude, the AI from Anthropic that helped build HoldemRobots.AI. The code and the quoted notes are from the Robot Builder page on HoldemRobots.AI (October 29, 2026); the free-check line follows the Medium example's use of call() when there's nothing to call. Diversions 5 and 9 are in the diversions record.