axiom-ai

Self-Taught Volleyball

An agent that learns Slime Volleyball purely by playing against its own past selves.

Build log

Status

Not started. This log is written by Claude Code during the cloud session that builds the demo, then lightly edited.

The brief

The prompt the session received, verbatim, and a link to the cloud session and PR.

Approach

What was chosen and why. Alternatives considered. Anything reused from open source, with license and link.

Timeline

Short dated entries as the work progressed: what was tried, what broke, what fixed it.

Numbers

Rough wall-clock time, number of turns, tokens or cost if known, bundle size, frames per second on a laptop and a phone.

What I would do next

Known gaps, stretch goals, ideas.

Original spec

Self-Taught Volleyball

Build a reinforcement-learning project in which an agent learns Slime Volleyball purely through self-play, plus a browser page that shows how it learned and lets visitors play against it.

This spec is the complete brief. Where it gives a number, use it. Where it is silent, choose the simplest option that meets the acceptance checklist, and record the choice in BUILD-LOG.md.

Goal

Show the process of a model teaching itself, not just the result. A visitor should come away knowing four things:

  1. What the agent sees: 12 numbers.
  2. What it can do: press 3 buttons.
  3. How it is scored: +1 or −1 per point.
  4. How that score makes it better: PPO updates, against a growing pool of its own past selves.

They should also see the agent go from flailing to competent across recorded checkpoints, and be able to play against any checkpoint themselves.

Hard constraint from the owner:

  • The agent never trains against, is evaluated against, or is compared with any fixed expert opponent.
  • The base repo’s built-in BaselinePolicy is not ported, not imported, not called and not mentioned on the page.
  • All measurement is relative to the agent’s own checkpoints.

How this project differs from other demos

Training is too slow for a visitor’s browser, so the work is split into three phases:

Phase Who Where Output
1. Build The build session (you) Cloud container, CPU only Training code, evaluation and export scripts, the web page, a parity test, and provisional data from a short smoke run so the page works end to end
2. Train Drew His Windows PC, native, no WSL A full training run, evaluated and exported into demo/data/ by one command each, then committed
3. Publish Drew, or a short follow-up session — Real numbers in BUILD-LOG.md, project.json status set to live

Phase 1 is your job. Phase 2 must need no judgement from Drew beyond running the commands in training/README.md.

Branching and status:

  • Branch from main after the design PR that contains this spec has merged. That PR already removes projects/tower-defense/ and adds this folder. Your PR changes only projects/slime-volley/.
  • Set status to building in your first commit.
  • Update BUILD-LOG.md as you go, per CLAUDE.md.
  • live is set in phase 3, never by you.

This does not break the CLAUDE.md browser-only rule. The Python code is never served; the site still runs entirely in the visitor’s browser from static files.

Base code and licensing

Base: hardmaru/slimevolleygym, Apache-2.0, commit 8ac22434fc5a587a3395311f7854aeda17d10303.

Port these parts only:

  • From slimevolleygym/slimevolley.py:
    • the constants block (lines 31–45)
    • setNightColors
    • Particle, Wall, RelativeState, Agent and Game
    • the state-observation path of SlimeVolleyEnv
  • Nothing else. Specifically exclude pixel mode, Atari mode, BaselinePolicy, rendering via pyglet, and OpenCV.

Licensing obligations (Apache-2.0):

  • Copy the base’s LICENSE to projects/slime-volley/LICENSE-slimevolleygym.
  • Every ported file, both Python and TypeScript, starts with a header that does three things:
    • names the source
    • states “Licensed under the Apache License 2.0”
    • states that the file was modified, and how (for example, “ported to TypeScript”, “BaselinePolicy removed”)
  • BUILD-LOG.md credits the base, with its link and commit.

Dependencies:

  • Training: Stable-Baselines3 (MIT), PyTorch, Gymnasium (MIT), NumPy.
  • Do not depend on the slimevolleygym package itself. It pins the old gym, pyglet and opencv-python. Vendor the ported code instead.
  • requirements.txt pins exact versions from plain PyPI, with no --index-url.
    • The PyTorch CPU index is blocked by the container’s proxy.
    • On Windows, the PyPI Torch wheel is already CPU-only, which is what we want.
    • On Linux, PyPI Torch pulls in CUDA libraries, several GB. Accept that in the container; it is only the smoke run.
    • Choose pins that publish both cp312-win_amd64 and cp313-manylinux wheels. The container runs Python 3.13; Drew uses 3.12. Record the pins and the reason in BUILD-LOG.md.
  • Web: no new npm dependencies. Draw everything, charts included, with Canvas 2D.

Files

projects/slime-volley/
  project.json  SPEC.md  BUILD-LOG.md  LICENSE-slimevolleygym
  media/                         screenshot(s)
  training/
    README.md                    Drew's runbook (see Phase 2)
    requirements.txt             pinned versions, plain PyPI (see Dependencies)
    .gitignore                   runs/, .venv/, *.zip, __pycache__/
    slime/
      __init__.py
      core.py                    ported physics + Game, no BaselinePolicy
      env.py                     Gymnasium env + self-play opponent pool
      policy_np.py               NumPy MLP forward pass (opponents, eval)
      train.py                   python -m slime.train
      evaluate.py                python -m slime.evaluate
      export.py                  python -m slime.export
      fixtures.py                python -m slime.fixtures (parity data)
    tests/                       pytest: determinism, mirror symmetry, export round-trip
  demo/
    index.ts                     mount(), layout, wiring, cleanup
    sim.ts                       TypeScript port of core.py
    policy.ts                    MLP forward pass from exported weights
    render.ts                    court, slimes, ball, lives
    watch.ts                     replay player
    play.ts                      human vs checkpoint
    panels.ts                    sees / decides / expects panels
    charts.ts                    rating curve, training curves, head-to-head matrix
    data/                        exported JSON (provisional in phase 1, real in phase 2)
    tests/parity.test.ts         node --test, see Parity
    tests/fixtures/parity.json   Python reference states (not shipped, not in the 3 MB budget)

The game, ported faithfully

Port the base’s physics exactly: same constants, same order of operations, same floating-point expressions. Read Game.step, Agent.update, Particle.checkEdges, Particle.bounce and Particle.limitSpeed and reproduce them line by line in both core.py and sim.ts.

Facts the builder must preserve:

  • World and timing: REF_W = 48, TIMESTEP = 1/30. A match ends when either side reaches 0 of its 5 lives, or after t_limit = 3000 steps.
  • The serve: each point starts with the ball at (0, REF_W/4), with vx ~ U(−20, 20) and vy ~ U(10, 25).
  • Serve delay: for INIT_DELAY_FRAMES = 30 frames after a serve, the ball does not move, but the agents do, and collisions are still checked.
  • Stale observation on a scoring step: when a point is scored, Game.step returns before calling updateState. The observation for that step is therefore the previous step’s state. Keep this.
  • Observation: 12 numbers from the agent’s own perspective, divided by 10. They are self x, y, vx, vy; ball x, y, vx, vy; opponent x, y, vx, vy. The x values are mirrored so both sides see the game the same way.
  • Action: three binary buttons [forward, backward, jump], interpreted as in Agent.setAction.
  • Reward to the right-hand agent: +1 when the ball lands on the left side, −1 when it lands on the right, 0 otherwise. A match score therefore lies between −5 and +5.

Details that matter for exact parity:

  • Serves:
    • Game.reset draws the first serve. newMatch draws a new one on every scoring step, including the match’s last point, so a match consumes points + 1 serves.
    • Draw order is vx, then vy.
    • Convert each to a Python float immediately. np.float64 scalar arithmetic is slower, and it turns division by zero into NaN with a warning instead of an exception.
  • The while isColliding nudge loop in bounce is reproduced as is.
  • Bounce when the centres coincide: abd == 0 raises in Python and gives NaN in JS. It is vanishingly rare. Guard both the same way: if abd == 0, use the normal (0, 1). Note the deviation in the header.
  • Square roots: use math.sqrt in Python and Math.sqrt in JS, never hypot.
  • Expressions: keep every expression’s operand order identical between the two languages.

Randomness:

  • core.py takes a numpy.random.Generator for the serves.
  • sim.ts takes a seeded PRNG (mulberry32) for its own play mode.
  • Replays do not depend on either: they carry their serves explicitly.

Training (training/)

Environment (slime/env.py)

  • A gymnasium.Env with:

    • observation_space = Box(-inf, inf, (12,), float32)
    • action_space = MultiBinary(3)
  • The learner is always the right agent. The opponent plays left and acts on agent_left’s observation.

  • reset(seed) seeds the serve generator.

  • step returns:

    • terminated when either side’s lives reach 0. This takes precedence: if lives hit 0 on step 3000, return terminated=True, truncated=False.
    • truncated at 3000 steps otherwise
    • an info dict containing {"lives": ..., "other_lives": ...}
  • The vectorised env is wrapped in VecMonitor, so episode rewards and lengths get logged.

  • Opponent: loaded from the champion pool at every reset().

    • With probability 0.5, it is the latest champion.
    • Otherwise, it is a uniformly random champion from the whole pool.

    This sampling across history is the stabilising change the base author recommends (Bansal et al. 2018). It is the one deliberate departure from the base’s self-play script.

  • The opponent acts stochastically: each button is sampled from its Bernoulli probability, using the env’s generator.

  • Champion zero is the uniformly random policy: each button is pressed with probability 0.5. It is not a network.

  • Opponents run through policy_np.py, a NumPy forward pass over exported weights. Do not load SB3 or Torch models inside subprocess envs.

  • The pool lives in runs/<run>/pool/ as champion_<gen:04d>.npz. Each env re-reads the directory listing at reset only when its modification time changes.

PPO (Stable-Baselines3)

The hyperparameters match the base’s PPO1 settings, translated to SB3:

Setting Value
Policy MlpPolicy (SB3 default: separate actor and critic, each [64, 64], tanh)
Parallel envs n_envs = 8, SubprocVecEnv
n_steps 512 (8 × 512 = 4,096 per update, the base’s batch)
batch_size 64
n_epochs 10
learning_rate linear schedule from 3e-4 to 0
clip_range 0.2
ent_coef 0.0
gamma 0.99
gae_lambda 0.95
device "cpu" (the network is about 10k parameters; a GPU only adds overhead)
Default total timesteps 20,000,000

One callback

A single SB3 callback does all of the following in the main process, after each rollout. Every interval below is a multiple of 4,096, so it lands exactly on an update boundary.

Champion promotion

This follows the base’s rule. When num_timesteps % 102_400 == 0 (every 25 updates, about every 100k steps):

  1. Copy the current actor weights into policy_np format.
  2. Play 100 matches in a separate env in the main process. The current policy plays right against the latest champion on the left. Both sides are stochastic and use a dedicated Generator seeded from the run seed and the step.
  3. If the mean score is above +0.5, write the current weights to the pool as the next champion generation. Log it.

Use NumPy for both sides here, not SB3 predict. NumPy is about 10 µs per step against about 150 µs.

Include promotion time in the ETA.

Checkpoints

Save the current policy weights (as .npz plus SB3 .zip) at the first update boundary at or after each of these milestones:

0, 50k, 100k, 250k, 500k, 1M, 2M, 5M, 10M, 20M (the final model).

  • Step 0 is the untrained, randomly initialised network, saved before learn() starts.
  • Each checkpoint’s step field is the milestone value, used for labels. Its actual num_timesteps is stored alongside.
  • When num_timesteps ≥ --steps, save the final model and return False to stop. SB3 would otherwise overshoot.
  • If --steps is smaller than 20M, keep only the milestones below it, plus the final model labelled with --steps.

Resume state

At every promotion check, also write:

  • runs/<run>/latest.zip
  • runs/<run>/state.json, holding the champion generation, the milestones already saved, the promotions list, and the accumulated wall-clock seconds

Write both atomically: write a temp file, then os.replace. Note that np.savez appends .npz to any name that does not end in it, so name temp files accordingly.

Logging

Write runs/<run>/progress.csv once per update with a custom appending CSV writer. Do not use SB3’s CSVOutputFormat, which truncates the file and would wipe history on resume.

Columns:

  • timesteps
  • wall seconds
  • mean episode reward (rollout/ep_rew_mean, against the sampled opponent)
  • mean episode length
  • policy loss
  • value loss
  • entropy: SB3 logs train/entropy_loss, which is minus the entropy, so negate it
  • approx KL
  • clip fraction
  • explained variance
  • champion generation

Command line

python -m slime.train --run <name> --seed <int> --steps <int> [--resume]
  • It prints steps per second and an ETA every update.

  • --resume:

    1. Loads latest.zip and state.json.
    2. Calls learn(total_timesteps=steps - model.num_timesteps, reset_num_timesteps=False). This keeps the linear learning-rate schedule correct.
    3. Appends to progress.csv.

    At most about 100k steps are lost on a crash.

Windows

  • All entry points use the if __name__ == "__main__": guard.
  • SubprocVecEnv(start_method="spawn").
  • No POSIX-only calls.
  • Paths use pathlib.

Evaluation (slime/evaluate.py)

python -m slime.evaluate --run <name> --matches 200

Who plays: every pair of saved checkpoints, plus the random policy, which is listed as “random”.

How each match is played:

  • Both sides act stochastically, from a fixed seed per pair.
  • Side swaps: half the matches with each checkpoint on the right.
  • Result: the side with more lives remaining wins. Equal lives at the 3,000-step limit is a draw.

Self-play: each checkpoint also plays --matches games against itself.

Outputs:

  • Rating: fit a Bradley–Terry model on the Elo scale (400 points per factor of 10 in odds), counting draws as half a win.
    • Regularise it: add one virtual draw between every pair of players. Without this, a player who never wins, such as random against late checkpoints, gets a rating of −∞.
    • Fit with minorisation–maximisation iterations to a tolerance of 1e-9.
    • Then shift so the random policy is 0.
    • A pytest checks that the fit is finite on a fully separated result table.
  • Head-to-head matrix:
    • Size (N+1)², with checkpoints in order and random last.
    • Each entry is the row player’s win rate against the column player, with draws counted as half.
    • The diagonal is the self-play win rate of the right-hand side, which should be about 0.5.
  • Per-checkpoint play statistics, from its matches against itself:
    • mean rally length (steps per point)
    • mean ball contacts per point. A contact is a step where the ball collides with an agent and did not collide with that same agent on the previous step.
    • the percentage of matches that reach the 3,000-step limit (a sign of long, competent rallies)
  • Run comparison: python -m slime.evaluate --compare <runA> <runB> … prints each run’s final-checkpoint rating, and runs a head-to-head between their final models.

Use multiprocessing with spawn, and show progress. Expect tens of minutes; print an ETA.

Export (slime/export.py)

python -m slime.export --run <name> --out ../demo/data

It first empties weights/ and replays/ in the output folder, so no stale smoke-run files survive. Then it writes the files below.

  • JSON is written with allow_nan=False.
  • The total must stay under 3 MB. Fail with a clear message if it doesn’t.

run.json

  • provisional (boolean)
  • run name, seed, total timesteps, wall-clock hours
  • CPU model and OS
  • library versions
  • hyperparameters
  • checkpoints: an array of objects, each with:
    • step
    • label (for example “1M”)
    • rating
    • rallyLength
    • contactsPerPoint
    • timeoutPct
    • championGeneration (the latest champion at that step)
    • weights (filename)
    • replay (filename)
  • matrix: row-major win rates, in checkpoint order
  • curves: progress.csv downsampled to at most 400 rows, with the columns listed under Logging
  • promotions: an array of {generation, step}

weights/<step>.json

  • Actor and critic layers, each {w: base64 Float32 little-endian, shape: [out, in]} and {b: base64}, in layer order.
  • Activations are tanh.
  • The actor’s 3 output logits go through a sigmoid to give button probabilities.
  • The critic outputs one value.

replays/<step>.json

  • One match of the checkpoint against itself, stochastic, from seed 1000 + its index.
  • It contains:
    • serves: an array of [vx, vy], one per point
    • actions: both sides’ button presses per step, packed as one character per step. The character code is 48 + rightBits + 8 × leftBits, with bits ordered forward = 1, backward = 2, jump = 4.
    • checks: the full game state every 30 steps, for verification
    • result
  • The browser re-simulates the match from serves and actions. Panels compute the probabilities and values from the weights live, so they are not stored.

Game state, used by checks and by parity:

  • Ball: x, y, prev_x, prev_y, vx, vy.
  • Each agent: x, y, vx, vy, desired_vx, desired_vy, life, emotion.
  • Delay: the delay-screen life.
  • Observations: both agents’ 12-value observations. Including these tests the stale-observation rule.

demo/tests/fixtures/parity.json (written by python -m slime.fixtures; not part of demo/data/):

  • 5 matches with uniformly random actions and recorded serves.
  • The full state at every step for the first 600 steps of each match.

The web page (demo/)

Data loading

  • Fetch the files with new URL('./data/…', import.meta.url), so Vite copies them to the build.
    • If Vite does not emit them that way, import the JSON statically with ?url imports instead.
    • Verify that npm run build output contains them.
  • When run.json has provisional: true, show a visible banner: “Preview data from a short test run. Full training results coming soon.”

Layout

The page has these parts, top to bottom:

  • Tabs: Watch | Play.
  • Checkpoint scrubber: a horizontal list of checkpoint chips (“0”, “50k”, … “20M”), each showing its rating. It is shared by both tabs.
  • Stage: the game canvas. It keeps the base’s 1200:500 aspect ratio, fills the width, sits on a ResizeObserver, and is HiDPI with dpr capped at 2.
  • Below the stage:
    • What it sees: the 12 labelled observation values as signed bars, updating every frame.
    • What it decides: 3 bars showing the probability of each button, with the sampled press highlighted.
    • What it expects: the critic’s value as a meter, with a scrolling sparkline over the current point. Caption: “Its own prediction of how the next few seconds will go: up means it expects to win the point.” The value approximates the discounted future reward over a horizon of about 3 seconds; say so in the explainer.
    • How it improved:
      • a rating-versus-training-steps line chart with the selected checkpoint marked
      • a toggle to the training curves (entropy, value loss, mean episode length)
      • the head-to-head matrix as a heatmap
  • Explainer: short prose sections, written for a non-specialist:
    • What it sees
    • What it can do
    • How it’s scored
    • How it learns (PPO in three sentences)
    • Why self-play (the champion pool and the promotion rule)
    • What the rating means: it is relative to its own past selves and the random player, not an absolute skill level
    • The numbers from run.json: hardware, hours and steps

Phone layout: panels stack under the canvas, the explainer collapses into <details> sections, and the scrubber scrolls horizontally.

Rendering

  • Port the base’s look with its night colours: the background, the ground, the fence with its round stub, the ball, and the slimes as half-circles with eyes that track the ball.
  • Port the “sad” eyes after losing a point, and the life coins.
  • Label the agent’s side “Agent (checkpoint N)”. In Play mode the other side is “You”.

Watch mode

  • Replays the selected checkpoint’s recorded match at real time (30 steps per second).
  • Controls: play/pause, ×1/×2/×4 speed, restart, and a step-by-step mode.
  • The panels follow the right-hand player.
  • During a replay, compare each checks entry to the re-simulated state. On a mismatch, log to the console and show a small “replay out of sync” badge. This should never appear once the parity test passes.

Play mode

  • Sides: the visitor plays left, and the selected checkpoint plays right.
  • Agent actions: stochastic, with a “deterministic” toggle that presses a button when its probability is greater than 0.5.
  • Timing: a fixed 30 Hz simulation with an accumulator, at most 4 steps per frame, rendered every animation frame.
  • Controls:
    • Keyboard: A/D or ←/→ to move, W, ↑ or Space to jump.
      • The visitor is the left player (dir = −1), so → or D is button 0 (“forward”, toward the net), and ← or A is button 1 (“backward”).
      • Map the keys to buttons this way. Do not invent a separate movement path.
      • Listen on the demo root (tabindex=0), not window, and focus it on canvas pointerdown.
      • Call preventDefault for handled keys, and ignore events from form controls.
    • Touch: three large on-screen buttons below the canvas, pointerdown/pointerup/pointercancel, supporting multi-touch so jump and move can be held together.
      • The buttons are styled touch-action: none; user-select: none.
      • Track presses per pointerId, so lifting one finger does not release another button.
  • The agent’s observation is agent_right’s observation, exactly as in training.
  • Match flow: first to 5 points, then a result card with “Play again” and “Try another checkpoint”.
  • Serves: use the seeded PRNG, with the same distribution as the base.

Lifecycle

  • mount() returns a cleanup function that:
    • cancels animation frames
    • disconnects observers
    • removes all listeners
    • empties the container
  • Pause animation when the demo is off-screen (IntersectionObserver). On resume, reset the accumulator.
  • If prefers-reduced-motion is set, start Watch mode paused.

Styling

Use the CSS variables and the .demo-controls class from src/styles/global.css. No external fonts.

Parity

  • demo/tests/parity.test.ts runs from the repo root with this command (Node ≥ 22.12, already required by package.json):

    node --experimental-strip-types --test projects/slime-volley/demo/tests/parity.test.ts

    Give the file path. A directory path fails with MODULE_NOT_FOUND.

  • The test file begins with // @ts-nocheck.

    • astro check type-checks every .ts file in the repo, and @types/node is not installed. Without the directive, the node:test, node:assert and node:fs imports fail the check.
    • Do not add @types/node.
    • sim.ts must not import any node: module.
  • Compare fields with === one by one, never deepStrictEqual. Python’s 0*-1 gives 0, but JavaScript’s gives -0, and deepStrictEqual treats those as different.

    • Imports between .ts files use explicit .ts extensions so this works without a bundler. Astro’s base tsconfig already enables allowImportingTsExtensions.
    • Every module the test imports (sim.ts and anything it pulls in) must use only erasable TypeScript syntax, because Node’s type stripping cannot handle the rest:
      • no enum, namespace or constructor parameter properties
      • type-only imports written as import type, which verbatimModuleSyntax already requires
    • sim.ts has no DOM access.
  • It loads demo/tests/fixtures/parity.json, replays every match in sim.ts, and asserts every state field equals the Python value exactly (===).

    • If exact equality fails, find and fix the operation-order difference.
    • Allow a tolerance only if the cause is a documented Math versus Python difference, and record it.
  • It also re-simulates every replays/*.json and checks its checks entries.

  • Add npm-free instructions to BUILD-LOG.md for running it. Do not change package.json.

Phase 1 smoke run (in the container)

  1. Create a venv in training/.venv and run pip install -r training/requirements.txt. On Linux this pulls in CUDA libraries. Delete the venv after the smoke run if disk space gets tight.
  2. Run pytest training/tests.
  3. python -m slime.train --run smoke --seed 1 --steps 300000.
  4. Evaluate with --matches 40.
  5. Export with provisional: true.
  6. Run python -m slime.fixtures.
  7. Run the parity test.
  8. Commit demo/data/.

Record the measured steps per second and the extrapolated time for 20M steps in BUILD-LOG.md.

Phase 2 runbook (training/README.md, for Drew)

The runbook must be followable without reading this spec. It covers:

  1. Prerequisites:

    • Windows 10/11
    • Python 3.12 from python.org
    • Node 22.12 or newer
    • Git
    • A clone of the repo with the build PR merged
  2. Setup. Run these in PowerShell, from the repo root:

    cd projects\slime-volley\training
    py -3.12 -m venv .venv
    .venv\Scripts\python.exe -m pip install -r requirements.txt
    • Every later Python command uses .venv\Scripts\python.exe directly. PowerShell’s default execution policy blocks activate, so never rely on it.
    • Note that the CPU build of Torch is intended.
  3. Train:

    .venv\Scripts\python.exe -m slime.train --run main --seed 1 --steps 20000000
    • Include the expected duration, from the phase 1 measurement scaled to a “modern 8-core CPU”, and what the progress output looks like.
    • Resume after a reboot or crash with the same command plus --resume.
  4. Optional: run seeds 2 and 3 as runs seed2 and seed3, then compare them:

    .venv\Scripts\python.exe -m slime.evaluate --compare main seed2 seed3

    Use the best run’s name in the next steps.

  5. Evaluate and export:

    .venv\Scripts\python.exe -m slime.evaluate --run main --matches 200
    .venv\Scripts\python.exe -m slime.export --run main --out ..\demo\data --final
    .venv\Scripts\python.exe -m slime.fixtures

    --final sets provisional: false.

  6. Check: from the repo root, run:

    npm ci
    node --experimental-strip-types --test projects/slime-volley/demo/tests/parity.test.ts
    npm run dev

    Then open /projects/slime-volley/ and confirm that the banner is gone and the matches look right.

  7. Phase 3, publish:

    • Create the branch data/slime-volley-main.
    • In BUILD-LOG.md, fill the “Numbers” section from run.json: hours, steps, CPU, final rating, and promotions.
    • Set status to live in project.json.
    • Run npm run check and npm run build.
    • Commit projects/slime-volley/, push, and open a PR titled feat(slime-volley): full training run data.
  8. Troubleshooting: a short list covering:

    • out-of-memory
    • slow progress
    • a run that never promotes a champion, and what to look at in progress.csv
    • export failing the 3 MB check

Build order

Commit after each step. Each step has a checkpoint.

  1. Port core.py. Then the Gymnasium env, policy_np.py and the pytest suite. Check:
    • Same seed and actions give identical states.
    • Mirror symmetry: swapping sides mirrors the observations.
    • Random-versus-random matches end correctly.
  2. Trainer: pool, promotion, checkpoints, CSV logging and resume. Check: a 50k-step run completes on Windows-safe code paths (spawn), and resume works.
  3. Evaluate and export, plus fixtures. Smoke run (phase 1 list). Check: the files validate, and the total size is under 3 MB.
  4. sim.ts and the parity test. Check: exact parity on all fixtures.
  5. Render and Watch mode with the scrubber. Check: the replays play, and the sync badge never appears.
  6. Panels and charts.
  7. Play mode, keyboard and touch. Check: a full match can be played in DevTools phone emulation.
  8. Explainer, runbook, final BUILD-LOG.md pass, screenshot.
    • Run npm run check and npm run build.
    • Leave status at building. Phase 3 sets live.

Cut list, in this order:

  1. The training-curve toggle (keep the rating chart).
  2. The head-to-head heatmap.
  3. Step-by-step mode.
  4. The ×4 speed.

Never cut the parity test, the “What it sees”, “What it decides” and “What it expects” panels, or Play mode.

Out of scope:

  • any fixed expert opponent or baseline
  • pixel observations
  • GPU training
  • running training in the browser
  • sound
  • multiplayer between two humans

Acceptance checklist

  • npm run check and npm run build pass. No new npm dependencies. The PR changes only projects/slime-volley/, and was branched from main after the design PR merged.
  • No code, data or text anywhere references BaselinePolicy or a fixed expert opponent. Verify with grep -ri baseline projects/slime-volley (hits in comments explaining its removal are fine).
  • pytest training/tests passes: - determinism - mirror symmetry - export round-trip: weights exported then loaded in policy_np.py reproduce the SB3 actor and critic outputs within 1e-5 - a finite rating fit on a fully separated result table - resume, by training 2 × 8,192 steps with --resume in between
  • Re-running export leaves no stale files.
  • The parity test passes with exact equality on all fixtures and replay checks.
  • The phase 1 smoke run completed, and the provisional data is committed under 3 MB, with the banner shown.
  • training/README.md lets a person with no context run phases 2 and 3 on native Windows. Commands are copy-pasteable, and each step’s expected output is described.
  • Watch mode replays every checkpoint in sync. All four panels update every frame. The rating chart marks the selected checkpoint.
  • Play mode works by keyboard on desktop, and by multi-touch buttons in phone emulation at 375×667. Both deterministic and stochastic agents work. Match end and restart work.
  • The explainer covers inputs, actions, reward, PPO, self-play and the rating’s meaning in plain language.
  • The canvas is sharp at dpr 2. Resize keeps the aspect ratio with no growth loop.
  • Cleanup stops everything. No console errors.
  • Apache-2.0 obligations are met: the LICENSE copy, and modified-file headers in every ported file. BUILD-LOG.md covers everything CLAUDE.md requires, including the smoke-run throughput and extrapolated phase 2 time.
  • media/ has a screenshot of Watch mode.