games: pace the ball off its own clock, and play both games faster - #378
Merged
Conversation
The ball in pong and breakout was still slow and still jiggled after the tick rate and the half-row grid were both fixed. Measured, two things were left, and they were separate. The jiggle was cadence. Rounding the true position to the lattice every tick moves the drawn ball when it crosses a column edge or a half-row edge, and those two are on unrelated schedules. When their periods are close but not equal — which is what a near-diagonal is, and what breakout launches at — they beat: breakout held a cell for 16ms, then 80ms, then 48ms, several times a second, and pong ran 16/32/48/64. The steps were the right size and the ball still looked like it was struggling, because nothing was moving at a rate. Whenever both crossings landed on the same tick it also lurched a diagonal 1.41 units in one frame. So the true position no longer decides when the ball is drawn, only which way it owes a step. Steps are paid out by a clock running at the ball's own speed, so it moves every 1/speed ticks at any angle, trailing the truth by under half a character. Worst jump is now exactly one unit, and the longest stall drops from 64ms to 32ms in pong and 80ms to 48ms in breakout. The slowness was just slowness: the old ball crossed the board in about three seconds. Both games now scale every tuned speed by a single PACE, the machine and the spin along with the ball, so the balance that makes a ball into the corner beat the pong machine is exactly the one that was tuned — only the clock it is played against changes. That takes the drawn ball from 20 steps a second to 43 in both games. Breakout's paddle goes to three columns a press to stay ahead of the faster ball. The new test pins the cadence rather than the speed, and fails against the old sampling even at the new pace. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ThreatCrush Security Scan97 finding(s) HIGH/CRITICAL: 5 | MEDIUM: 41 | LOW: 51
…and 47 more. Full results in the Security tab. Snippets are redacted; ThreatCrush never prints matched credential material. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The ball in
/games breakoutand/games pongwas still slow and still jiggled after #373 (tick rate) and #376 (half-row grid). Measuring the drawn ball rather than the physics showed two separate causes left.The jiggle was cadence, not step size
Rounding the true position to the lattice every tick moves the drawn ball whenever it crosses a column edge or a half-row edge — and those two are on unrelated schedules. When their periods are close but not equal (a near-diagonal, which is exactly what breakout launches at) they beat against each other:
The steps were the right size and the ball still looked like it was struggling, because nothing was moving at a rate. And whenever both crossings landed on the same tick, it lurched a diagonal 1.41 units in a single frame.
So the true position no longer decides when the ball is drawn — only which way it owes a step. Steps are paid out by a clock accruing at
|vx| + 2|vy|lattice units per tick, so the ball moves every1/speedticks at any angle, trailing the truth by under a unit (under half a character).The slowness was just slowness
The old ball crossed the board in about three seconds. Both games now scale every tuned speed by a single
PACE, the pong machine and the paddle spin along with the ball, so the balance that makes a ball into the corner beat the machine is exactly the one that was tuned — only the clock it is played against changes. Breakout's paddle goes to three columns a press to stay ahead.Result
Testing
Full suite green (1853 tests, 0 failures). The new test pins the cadence rather than the speed, and it bites — sampling the old way at the new pace still fails it:
The existing balance tests (
the machine can be beaten, but not by doing nothing,a wall can be cleared, and cannot be cleared by leaving the paddle alone) pass unchanged at the new pace.🤖 Generated with Claude Code