Watching bots
Watch a trained bot play in RLViser with just watch.
4 min read
just watch shows a trained bot playing in RLViser, with a one-line console summary of every game.
RLViser opens by itself if it isn't running:
just watch runs/selfplay/main-1v1-s11 # newest checkpoint vs the scripted ball chaser, until Ctrl-C
just watch runs/selfplay/main-1v1-s11 --progression # 6 checkpoints from earliest to final, same kickoff
just watch runs/selfplay/<running-run> --follow # a run still training: newest checkpoint before each game
just watch runs/selfplay/main-1v1-s11/final.pt --opponent self --training-starts
just watch runs/t1/<aerial-run> --best --speed 0.5 # single-agent tasks work too (no opponent)The target is a checkpoint (.pt) or a run directory (its newest checkpoint, or best.pt with
--best).
How it works. Each game is played in Python with the checkpoint's own task (stored in the
checkpoint, so later edits to tasks/ don't matter), exported as a scenario, and streamed with
physlab view --live, which replays it exactly in RocketSim. The next game plays while the current
one streams, so there's no gap. Inference runs on one CPU thread, so it can run next to training; the
run directory is only read. Scenarios go to tmp/watch/ and are deleted after streaming unless
--keep.
| Option | Meaning |
|---|---|
--opponent X | Match tasks: ball_chaser (default), idle, random, self, prev:N (the checkpoint N saves earlier), or a checkpoint path (also from another run) |
--follow | Reload the run's newest checkpoint before each game. Waits for the first one, and retries one that's still being written |
--progression [--rungs 6] | Checkpoints spread over training (log-spaced, first and last included), each playing the same start. Prints each one's evaluation score and rating, and a summary table at the end |
--episodes N | Games to play (default: until Ctrl-C). With --progression: per checkpoint (default 1) |
--speed S | Playback speed (1 = real time). RLViser's speed keys multiply it |
--seed S | First start seed, from the task's held-out evaluation seeds |
--training-starts | Start from training seeds instead: every kind of starting state, not only kickoffs |
--sample | Sample actions instead of always taking the top one |
--task FILE | Play on another task file |
--port P | Stream to another UDP port instead of the RLViser that just watch opens. 40244 is the Command Center's browser viewer |
--snapshot DIR | Also save every game as DIR/<game>.rlvsnap for the web viewer. With --no-stream, only save |
--best | With a run directory: play its best.pt |
--meshes-dir DIR | Collision meshes (default: the repo's collision_meshes) |
--physlab BIN | The physlab binary that streams (default target/release/physlab[.exe]) |
--out-dir DIR | Where scenarios are written (default tmp/watch) |
--device, --keep, --no-stream, --no-color, --verbose | Inference device (default cpu); keep the scenarios; play without RLViser; plain output; show physlab view's output |
The console first prints what is being trained (task, rules, reward weights, run progress) and
which RLViser car is which: the bot is always Blue, car 1, so key 1 follows it. Then, per game:
the checkpoint and its step;
the result: WIN, LOSS or DRAW for matches, SUCCESS, FAIL or TIMEOUT for single-agent tasks;
who scored (and own goals), the duration and the start;
the checkpoint's evaluation score (from
metrics.jsonl) and rating (fromratings.json; relative to one run, so don't compare across runs);touches per car, and the bot's reward with its largest reward terms.
Notes:
Each game is one
physlab viewprocess, starting from tick 1. RLViser accepts the restart because it only drops frames whose tick count equals the previous one.RLViser's pause and speed keys work when the current
physlab viewcan bind127.0.0.1:34254. If another replay into the same RLViser is running, both streams mix, so stop the other first.Tests (
python/tests/test_watch.py) stream to their own UDP listener, never to RLViser.
Saving games as snapshots#
--snapshot DIR saves each game as a snapshot file that the web viewer plays back, for example to
put a game in a page:
just watch runs/selfplay/main-1v1-s11 --progression --snapshot tmp/snapshots --no-streamEach file is written with physlab view --live <scenario> --export <file>, the same replay that
streams to RLViser, at 30 frames per second. The console prints the path under the game's line.
Without --no-stream the game still streams to RLViser as well.
Known gaps#
Line overlays drawn on top of the 3D view were never built.