Recipes

Short end-to-end walk-throughs for common goals.

Each recipe assumes you've installed the kit and have a terminal in its root.

"Make me a first agent."

Imitation learning on the equity bot, then verify. Produces a working, admission-ready file in a few minutes.

python examples/02_clone_equity_bot.py --out cloned.npz
python tools/check_agent.py cloned.npz

cloned.npz beats the calling station and random play, and is a sound base for anything else. Upload it directly if you like.

Alternative: use the platform baseline (baselines/baseline.npz) instead of cloning. It's considerably stronger.

"I just want to upload something right now."

python tools/check_agent.py baselines/baseline.npz

If the check passes (it does), upload baselines/baseline.npz. You're on the ladder.

"Make my agent beat the baseline."

Train from the baseline, with it and other agents in the pool, and judge honestly:

python examples/04_parallel_train.py \
    --init baselines/baseline.npz \
    --add-opponents baselines/baseline.npz \
    --out runs/mine

Then measure with many thousands of deals:

python tools/evaluate.py runs/mine/agent.npz --vs baselines/baseline.npz --deals 10000 --jobs 8

Upload only if the result is clearly positive (|X| > Y in the output).

"Build a specialist vs. the baseline."

Train only against it. Finds its weaknesses the fastest — but the result is a specialist that may lose to everyone else.

python examples/04_parallel_train.py \
    --init baselines/baseline.npz \
    --opponents baselines/baseline.npz \
    --out runs/exploiter

Use this to understand the baseline's blind spots, then take those insights into a mixed-pool run.

"I have an idea for a strategy."

Three-step workflow:

  1. Write it as a Python player (see EquityBot.choose and PairsAndAces in examples/01_play_bots.py for shape).
  2. Test it with play_match in a script — does it beat the bots you'd expect it to beat?
  3. If yes, clone it into a network with examples/02_clone_*.py (replace the teacher).

The result is a network that behaves like your strategy. Then you can improve it with PPO from there.

"Improve a run I'm iterating on."

Train from last checkpoint, evaluate against last checkpoint:

python examples/03_selfplay_ppo.py --init runs/v4/agent.npz --out runs/v5
python tools/evaluate.py runs/v5/agent.npz --vs runs/v4/agent.npz --deals 5000 --jobs 8

Keep the new one only if it beats the old one by more than the error bar.

"The upload was rejected."

Run the checker locally — it prints the exact server message:

python tools/check_agent.py my_agent.npz

Most common causes:

  • Trained on a different observation size.
  • A softmax or activation after the last layer baked into the weights.
  • obs_std with zeros (use agent_file.safe_std).
  • NaN weights (diverged training run).

"It plays strangely."

Open the version page on the site and look at the per-button shares in the admission report. A network that presses one button almost always (all-in, fold) usually means:

  • Under-trained.
  • Trained against one opponent only.
  • Something leaked past the loss masking.

Re-check your training setup against Pitfalls.

"Is my kit current?"

python tools/check_agent.py my_agent.npz --api https://<site>

Compares this kit's contract digest with the site's active environment. A new environment means re-training; the contract changed.