Screen recording of the first graph: 129 bodies learn from zero (sped up 12x), the graph stops itself at generation 16 when the average walker (orange) passes the walking test, and its walk replays at real speed. Generation 13 went past the distance line but failed another part of the test (falls, steps or time in the air).
A population of stick-figure ragdolls starts with blank controllers and learns to walk, entirely inside the Desmos graphing calculator. The physics, the controller, the learning rule and the test that decides "it walks" are all Desmos expressions. Python only writes those expressions and checks them against a numpy copy of the same model.
| Graph | What happens | Time on a laptop |
|---|---|---|
| Learns to walk | 129 bodies learn from zero. Learning stops by itself the first time the average walker passes the walking test (generation 16, 5.28 m in 5 s), then the graph replays that walk. | about 5 minutes |
| Learns to keep walking | 97 bodies practise on 5 s windows that continue their own walk and take a 20 s walk from a standing start as an exam. Learning stops after two exam passes in a row, then it replays the 20 s walk with the camera following. | about 40 minutes |
Collapse the expression list (the arrows at its top right), then press play on the ticker. Both graphs pin Desmos's random seed, so every run draws the same noise. In Chrome on the laptop we built them on, reloading the first saved graph reproduced its original run to 6 digits (it stops at generation 16 with 5.283039 m). We have not tested other browsers or CPUs, and as the numpy note below shows, last-digit differences can grow into a different run.
The second graph's learned walker replaying its 20 s exam inside Desmos: the first 16 s, at real speed (one frame per Desmos tick of 0.1 simulated seconds), cropped to follow the walker.
- Body. A ragdoll in the style of Jakobsen's "Advanced Character Physics" (2001): six point masses, Verlet integration, bone-length constraints and joint-angle motors, solved with parallel (Jacobi) passes because Desmos evaluates whole lists at once. The motors are translation-neutral, so they cannot push the body along by themselves, and their speed is capped, which acts as a strength limit.
- Brain. A linear policy, one layer with tanh: 13 inputs (torso angle and spin, four joint angles, hip height and speed, two foot contacts, a clock as sine and cosine, a bias) mapped to 4 joint targets. That is 52 numbers.
- Learning. Augmented Random Search (Mania, Guy and Recht, 2018). Every episode, each random direction in weight space is tried with both signs next to the noise-free average, all bodies walk at once, and the average moves toward the directions that went farthest. Fitness is distance, minus a penalty for time with both feet off the ground beyond 15%, which rules out hopping and running.
- The walking test. The noise-free average must cover at least 0.8 m/s, never fall, take at least 3 alternating single-support steps per foot per 5 s, and keep both feet off the ground less than 25% of the time. The graph counts the steps itself.
- Making it fit in a calculator. Each physics family (all bones, all motors, all four policy outputs) is one vectorised formula over the whole population, the four constraint passes are nested function calls, and one ticker action advances six physics steps.
The second graph wraps the same learner in a practice-and-exam loop, because walkers that pass a 5 s test tend to fall soon after:
flowchart LR
W["5 s practice window<br/>(continues the last walk)"] -->|"passed, but not twice in a row"| W
W -->|"failed"| R["next window starts<br/>from a standing pose"]
R --> W
W -->|"passed twice in a row"| E["20 s exam<br/>from a standing pose"]
E -->|"failed"| R
E -->|"passed once"| E
E -->|"passed twice in a row"| S(["learning stops,<br/>the walk replays"])
Every episode, practice or exam, also updates the weights; after the first pass the random search takes smaller steps.
proto/ holds a numpy reference of the same model (sim.py physics, walkbar.py walking test, ars.py learning), and check_desmos.py compares the graphs against it. It bakes numpy's random noise into a test graph, lets Desmos run one episode, and compares every body.
- One 5 s episode of all 129 bodies agrees to about 2e-12 in fitness and 2e-14 in the learned update, with the same falls, step counts and verdict.
- For the second graph, a practice window that continues a walk (including the carried pose and clock) and a 20 s exam also match, and the weights learned inside Desmos, re-run in numpy, walk 17.683 m in 20 s against the graph's 17.684 m.
- Rounding differences grow over long walks because the gait is chaotic: they reached 1e-9 to 1e-6 m over 20 s in our checks, and metres within 15 s for one unstable walker in the sweeps. So long walks are compared on falls and verdicts, not to the last digit.
- The same chaos makes numpy training depend on the CPU. numpy picks vectorised code by instruction set, and its last-bit differences grow through the walk: seed 0 passes at generation 13 on our laptop (AVX2), at 26 on the same laptop with AVX2 turned off, at 19 on a GitHub test machine with AVX-512, and at 13 on one with AVX2 only. So the tests check that training passes, not at which generation.
- On every push, GitHub Actions runs the numpy side: the trainer tests, and
test_readme_claims.py, which checks thatgen_desmos.pystill writes the exact files behind both saved graphs and that numpy training from seed 0 still reaches the walking test. The comparison against Desmos itself needs a browser, socheck_desmos.pyis run by hand.
| Result | |
|---|---|
| 5 s graph, inside Desmos | Two from-zero runs with different seeds both passed, at generation 17 (5.53 m) and 16 (5.28 m); the second is the saved graph. 4.9 minutes on a 15 W laptop CPU (Intel i7-1255U, no GPU). |
| Long-walk graph, inside Desmos | Passed the 20 s exam twice in a row after 193 episodes and 42 minutes. Its walker covers 17.7 m in 20 s from a standing start. |
| Training recipes | Chosen in numpy, not guessed: 62 configurations for the 5 s recipe (24 of 24 seeds pass, median 5.3k simulated steps, about ten times fewer than the first recipe), and a second sweep for the long walk (22 of 24 seeds, median 36k steps). Tables in proto/sweep/results_all.txt and results_long.txt. |
| Limits | The learned gait limps (one stance is longer) and the torso pitches a lot. The long walker falls at 42 s, and with its start pose nudged by up to 1 mm, 64% of its 20 s walks still pass. The physics is simplified: motors turn joints toward their targets by a capped angle each step, with no torque, energy or actuator model, so this is learned walking in a simulation, not a controller for a real robot. |
gen_desmos.py --gait adds a third recipe: after the first pass, the random search only explores mirror-symmetric changes (legs swapped, clock shifted half a period), each update pulls the weights toward their mirror image, the torso angle is penalised, and the exam also requires an even gait. In numpy (proto/sweep/results_gait.txt) its walkers have stance asymmetry 0.014 instead of 0.37, a mean torso tilt of 7 degrees instead of 27, and 13 of 14 walk the full 60 s; but only 14 of 24 seeds get there within 100k simulated steps. The graph matches numpy episode by episode. One 90-minute run inside Desmos passed one gait exam (25 m in 20 s) but not two in a row, and was stopped.
As far as we could find, nobody had trained a walking body inside Desmos before, but this stands on a lot of community work. We searched the text of all 27,442 r/desmos posts up to 2026-10-24, plus YouTube, X, Hacker News and GitHub:
- Walking in Desmos has so far been animation: procedural inverse-kinematics walkers such as a 3D spider, and keyframed stick figures, with no dynamics and no learning.
- Learning in Desmos: Q-learning, neural networks trained by evolution to steer dots, a recurrent network trained in a graph to steer a thrusting dot, and a sprite that learns to dodge obstacles with reinforcement learning.
- Physics in Desmos: the JellyCar soft-body graph and many particle and gravity simulations.
What we did not find is an articulated body with contact physics whose controller is learned inside the graph. The search matched keywords in post titles and text, so a post with a vague title and only a video could have slipped past it.
Requirements: Python 3 with numpy and matplotlib (pip install -r requirements.txt gives the versions the results were made with).
python3 proto/ars.py 200 0 # train in numpy until the walking test passes (seed 0: generation 13 on our laptop; it depends on the CPU)
python3 proto/render.py theta_s0.npy strip.png # filmstrip of the learned gait
python3 gen_desmos.py learn.json --paused # the 5 s learning graph (byte-identical to the first saved graph's file)
python3 gen_desmos.py long.json --long --dirs 48 --top 24 --paused # the long-walk graph (byte-identical to the second one's)
python3 gen_desmos.py gait.json --gait --dirs 48 --top 24 # the gait recipe
python3 gen_desmos.py walker.json --theta theta_s0.npy --nu 0 # replay a numpy-trained walker in Desmos
python3 check_desmos.py prepare zero 12 test.json expected.json # an episode to compare against numpy
python3 test_readme_claims.py # the saved graph files and the generation-13 claim
cd proto/sweep && python3 test_train.py && python3 test_long_train.py # trainer testsTo load a generated file: open https://www.desmos.com/calculator, open the browser console, run Calc.setState( followed by the file's contents and ), collapse the expression list, and press play on the ticker.
| Path | What it is |
|---|---|
gen_desmos.py |
Writes the Desmos graphs (5 s, --long, --gait). |
check_desmos.py |
Builds test episodes with numpy's noise baked in, and the numpy results to compare with. |
test_readme_claims.py |
Checks the README's numpy-checkable claims; CI runs it with the trainer tests (.github/workflows/tests.yml). |
proto/ |
The numpy reference: sim.py (physics), walkbar.py (walking test), ars.py (learning), render.py (filmstrips). |
proto/sweep/ |
The recipe sweeps behind every training choice, their result tables, tests, and the trained walkers. |
evidence/ |
Screenshots, filmstrips and curves; evidence/LOG.md gives the numbers behind every claim. |
docs/, tools/ |
The README figures and the script that draws the body diagram. |
- After fusing the physics into a few vectorised functions, the cost per tick grows with list length (about 7, 5, 4.3 and 3 ticks per second at 65, 97, 129 and 193 bodies on this laptop). Run several physics steps per tick, and keep the state written back by actions small.
random(n, seed)is reproducible only together with the graph's top-levelrandomSeed. A state loaded without one gets a fresh seed on every load.- A browser tab that has loaded several heavy graphs can run three times slower than a freshly loaded one; a background tab, or a screen recorder, slows it much more.
- The ticker's elapsed-time variable is
\operatorname{dt}; plaindtparses as d times t.\tauis a built-in constant, so it cannot be a slider. Any one-variable function definition gets plotted, so hide helpers. - Multi-assignment actions are simultaneous, conditional actions work (
\left\{k<T:A_{1},A_{2}\right\}), and a number written next to a bracket (0.08[1...n]) parses as indexing; write0.08\cdot[1...n].




