why testing matters
$ git blame pacman
waiting“affirmative”
Nothing stopped him.
A check in the middle of each square.
Only if a jump lands near the middle.
When the jumps are big.
Fewer frames a second.
In the middle of each square he asks:
turn? keep going? stop?
The screen is redrawn about 60 times a second.
Each time, he jumps a little bit. Each dot is one jump.
A jump hardly ever lands exactly in the middle,
so the game checks for close enough.
Every square gets a check. He sees the wall coming and stops.
A big jump can hop right over the zone.
No check → nobody tells him to stop → into the wall.
The jump is so small he’s still in the zone —
snapped back to the middle, every frame. He never moves.
Steady frames: only 23–24 fail.
Wobbly, real ones: 20–35. Above about 65: frozen.
I made the browser pretend to be slow.
Then I could replicate it every time.
arrow keys or a controller · LB / RB change computer · START restarts
on slow he can only turn at every other square: a skipped check is a skipped turn
Don’t ask “am I near a middle right now?”
Ask “which middles did I pass?” — and stop at each one.
Walk to the middle → check → walk what’s left.
Big jumps, tiny jumps — every middle gets its check.
// old: only if a jump lands near a middle
if (nearMiddle(pac)) decide(pac);
move(pac, jump);// new: stop at every middle we pass
travel(pac, jump); // calls decide()
// at each middlefunction travel(pac, distance) {
while (distance > 0) {
if (atMiddle(pac)) decide(pac); // turn? stop?
if (pac.stopped) return; // wall ahead: throw the rest away
const toMiddle = distanceToNextMiddle(pac);
const step = Math.min(distance, toMiddle); // never past a middle
moveBy(pac, step);
distance -= step;
}
}
arrow keys or a controller · LB / RB change computer · START restarts
// move, and if you hit a wall, push back
if (!hitsWall(pac, wanted)) go(wanted);// stop at every middle and decide
travel(pac, jump);Both are holding ↑. He’s exactly as wide as the corridor,
so bumping only fits through the gap if he’s perfectly lined up.