Frame Perfect
Step Kettle into a wall, one frame at a time
Kettle is the course's small platformer. Every picture here is the game itself, run from the same code the course's checks run. This is level 2, frame 63 of a run found by breadth-first search, the search you write in the course. Kettle is in the air, moving right at 6 px a frame, toward a wall one tile (8 px) thick and too tall for Kettle to clear from this height.
| Frame | Buttons | x (px) | vx (px a frame) |
|---|
x is Kettle's left edge; Kettle is 6 px wide. The wall covers x 272 to 279.
Beat level 1's par by hand, with on-screen buttons and frame advance.
What you build
Each level sets a par, a frame count to beat; level 2's is 100 frames. With the game working as its makers meant, the best run takes 186. Over eight lessons you write the tools speedrunners use, in JavaScript for Node, and use them to find the two bugs that make par possible:
- A movie player. A movie is a run saved as a file, one line of buttons per frame, and the game plays it back the same way every time.
- Savestates and a desync finder. Go back to any frame, and find the first frame where two versions of the game disagree: seven comparisons for a 109-frame run.
- A memory watch and a model of the jump. Read the game's 32 bytes of memory and predict Kettle's arc to the sub-pixel.
- Searches that prove a route is the fastest. Breadth-first search and A*, which merge runs that reach the same state, so the search never repeats work it has done.
- A minimiser and a random-number steerer. Cut a run down to the presses a glitch needs, and steer the game's random generator so a bell drops its stone block in whichever of its four places you choose.
The last lesson is level 3, which no other lesson shows; you finish it with the toolkit you built and nothing else. You back every claim with a movie, and code you didn't write replays it on the untouched game.
Start the course
You need Node.js 22 or newer and to write JavaScript for Node comfortably: functions, loops, arrays, Map and Set, and modules. On a computer, clone the public project and open lesson 01 in your terminal:
git clone https://github.com/itsHabib/free-to-learn.git
cd free-to-learn
git switch --detach ec2d659ea97b56bcb4e003eaf36b4e99e5c3ca89
cd courses/frame-perfect
node lab.mjs lesson 01 ./work