Skip to lesson
Flawless Poker
Galaxy Bot AcademyGetting Started With Poker Bot Programming
BEGINNER · 12 MIN READ · GETTING STARTED WITH POKER BOT PROGRAMMING

Build Your First Decision Function

Learning objectiveReturn a simple legal action without guessing raise sizes.

Understand the idea

Start with the legal object, not a memorized action list. Checking is free; calling pays chips; folding gives up the hand. A beginner rule can cap calls at a small number of chips, then fold. This is a teaching baseline, not a profitable strategy.

A raise is legal only if legal.raise is true and its total target is an integer between minTo and maxTo. Leave betting out of your first function. Once tests cover check, call, and fold, add a separately tested raise branch.

At the poker table

Facing 40 chips with a 1,000-chip stack, this example folds because the cap is 20. Facing a free check, it checks.

Code and decision sketch

Python
def choose(observation):
    legal = observation.get('legal') or {}
    if legal.get('check'):
        return {'kind': 'check'}
    if legal.get('call') and legal.get('callAmount', 0) <= 20:
        return {'kind': 'call'}
    if legal.get('fold'):
        return {'kind': 'fold'}
    raise ValueError('No supported legal action; inspect observation')

Common mistake

Do not send {'kind':'raise','to':20} merely because you want to add 20 chips. The target is the seat's total bet, and the legal bounds are authoritative.

Try it yourself

Write three observations that trigger check, call, and fold. Verify the returned kind is marked true in legal.