Physics that learns from a recording

Keep your simulation. Let a recording set its constants.

1 A recording, and a game engine that doesn’t match it

You filmed a real ball (the dots). Your game's physics has three constants that someone eyeballed, and its ball (the line) lands in the wrong place.

the physics code unrolled into one Handwired net

  • furthest from the recording –
  • net replay vs plain JS, max difference –
  • frames below the floor 0

● recording — your physics - - generic model ··· real ball (new throw)

2 Predict

Learning moves only GRAVITY, DRAG and BOUNCE. Then you throw a new ball, harder and from lower down, that was never recorded. Will the learned physics follow the real ball?

3 Throw a new ball

(learn first)

4 The foil: a generic model of the path

A common shortcut: fit a neural net (frame number and throw → position, 5→16→2) to the recording.

Reach for Handwired when you have a simulation you believe in and measurements it should match: fit its constants, and keep the simulation.

The “recording” is simulated: the same step with hidden constants (GRAVITY 0.5, DRAG 0.012, BOUNCE 0.72) and ±0.4 px of camera jitter, 72 frames. The step is unrolled 72 times into one circuit (2,379 operations); the floor is an exact comparison and select. A bounce is differentiable in its height but not its timing, and gradients through many frames can explode, so learning starts on the first 12 frames and lengthens the window to all 72. Replay is float32 in the net and float64 in JavaScript, so the paths agree to the stated difference, not bit for bit.

Loading Handwired…