Imitation learning

Clone a hand-written strategy into a network — the fastest path to a working agent.

Imitation learning (a.k.a. behavior cloning) turns any function observation → action into a neural network with the same behavior. For this platform, the "teacher" is usually a hand-written bot or a simple rule — and the "student" is the MLP that will be uploaded.

It's the fastest useful training you can do: no reward engineering, no exploration problems, no credit assignment. You collect decisions, you minimize a classification loss. Done in minutes.

When imitation is the right tool

  • You need a working baseline, fast.
  • You've written (or can write) a passable bot in Python and want a network with the same behavior that you can then improve with RL.
  • You want to bootstrap PPO from something non-random — self-play from scratch is much slower and less stable than self-play from a cloned policy.

When imitation is not the right tool: when your teacher is weak. Imitation is a ceiling — your network will be at best as strong as the teacher. For a strong result, use imitation to initialize, then RL on top.

The shape of the loop

Every discipline's kit ships a worked example. For poker it's examples/02_clone_equity_bot.py. The steps are:

  1. Collect decisions. Play a lot of matches between the teacher and an opponent. For every decision the teacher makes, record (observation, chosen_button).
  2. Train. Fit an MLP to predict chosen_button from observation. Cross-entropy loss. The network architecture should match (or be smaller than) what you intend to upload.
  3. Export. Save the trained weights as the environment's upload format, using the kit's export helper.
  4. Check. Run the admission checker locally. Fix anything it complains about.
  5. Evaluate. Run the evaluator against the teacher. A good clone wins +0..+30 bb/100 against the teacher — it doesn't need to beat it by a lot.

Observation normalization

Collect your observations with the kit's own interface.observe(view) — the same function the server uses. During training, compute the mean and std of each of the 180 inputs and save them into the file as obs_mean / obs_std (use safe_std for zero-variance features).

Do not normalize observations outside the file. See Pitfalls.

How much data do you need?

For a 180-input, 6-output network a few hundred thousand decisions is already plenty. The clone example in the kit collects ~1M decisions by default and converges in a handful of epochs on a laptop.

Mixing teacher and opponent

If you only collect decisions from the teacher vs. one opponent, your network sees only one distribution of boards. Collect against several opponents (the calling station, equity bot, random, snapshots of previous networks) so the clone handles varied play.

From clone to strong agent

The usual pipeline:

  1. Clone a decent hand-written strategy. 5 minutes.
  2. Verify the clone passes admission and is in the right neighborhood of the teacher. 5 minutes.
  3. Run PPO from the clone against a mixed pool. Hours to days, depending on compute.
  4. Evaluate the final agent against earlier snapshots. Only keep it if the win is larger than the ± column.

See Self-play PPO for step 3.