Public: anyone can read this; the crew can change it.

Migrated from github.com/amirmushichge/pixel-plays

Skipping Rope rules: a tested `skipping-rope/rope.js` where you jump the turning rope as it quickens and more skippers join, from plain data, in a two-file pull with a test file that runs in under a second #291

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Skipping Rope rules are in skipping-rope/rope.js, with skipping-rope/rope.test.mjs beside it. No other file is touched. All 10 tests pass, and bun test skipping-rope/rope.test.mjs ran in 54 ms in the last run (39 ms in an earlier one).

Notes

shipped production is serving it deploy ab54f53

opened this

Skipping Rope rules are in skipping-rope/rope.js, with skipping-rope/rope.test.mjs beside it. No other file is touched. All 10 tests pass, and bun test skipping-rope/rope.test.mjs ran in 54 ms in the last run (39 ms in an earlier one).

bun x tsc --noEmit printed only its help text, which looks like there is no tsconfig in the repo, so it gave no type check. The repo has no docs/VISION.md, no scripts/gate.ts and no scripts/fast.ts, so those steps didn't apply. I only ran this one test file, not the full suite.

What the rules do

  • API: start(), tick(state, dt), jump(state), angle(state) and airborne(state) take and return plain data. tick and jump return { ok, state, why }, and a refused call returns the same state it was given. There is no DOM, no timers and no Math.random.
  • Rope angle: the angle is 1 - (nextCross - t) / period, a function of time alone. A tick that spans a ground pass is split at the exact pass time, so how time is sliced doesn't change the result.
  • tick: dt must be a finite number above 0, otherwise it is refused with bad-dt.
  • jump: it lifts the skipper for 0.5 s and is refused with in-air while still airborne.
  • Clear or catch: a skipper in the air when the rope reaches the ground clears it and scores 10 points. A skipper on the ground is caught, and the game ends with You are caught: N skips, score S. Landing exactly as the rope passes counts as a catch.
  • Quickening and joining: every 3 clears the period shortens by 0.125 s, from 1 s down to a floor of 0.625 s. Another skipper joins, up to 4, and each one adds 5 points to every later clear. The clear that triggers a join scores with the line as it stood.
  • Win: 12 clears ends the game with You win: N skips, score S.

Choices to check

  • The floor is 0.625 s, not 0.5 s. At 0.5 s the game would have been won before the floor was ever reached. With 0.625 s the floor is hit at clear 9, and the clamp is exercised at clears 12 and beyond.
  • Time is summed in floating point. The tests use times that are exact in binary (1/64 s, 1/16 s), so "however time is sliced" is checked exactly. That caveat is in a comment in rope.js.

Not done: no page, no catalogue entry and no dependencies, as the issue asked.

Try it: bun test skipping-rope/rope.test.mjs

🤖 Generated with Claude Code

Closes #270

commented

Skipping Rope rules are in skipping-rope/rope.js, with skipping-rope/rope.test.mjs beside it. No other file is touched. All 10 tests pass, and bun test skipping-rope/rope.test.mjs ran in 54 ms in the last run (39 ms in an earlier one).

bun x tsc --noEmit printed only its help text, which looks like there is no tsconfig in the repo, so it gave no type check. The repo has no docs/VISION.md, no scripts/gate.ts and no scripts/fast.ts, so those steps didn't apply. I only ran this one test file, not the full suite.

What the rules do

  • API: start(), tick(state, dt), jump(state), angle(state) and airborne(state) take and return plain data. tick and jump return { ok, state, why }, and a refused call returns the same state it was given. There is no DOM, no timers and no Math.random.
  • Rope angle: the angle is 1 - (nextCross - t) / period, a function of time alone. A tick that spans a ground pass is split at the exact pass time, so how time is sliced doesn't change the result.
  • tick: dt must be a finite number above 0, otherwise it is refused with bad-dt.
  • jump: it lifts the skipper for 0.5 s and is refused with in-air while still airborne.
  • Clear or catch: a skipper in the air when the rope reaches the ground clears it and scores 10 points. A skipper on the ground is caught, and the game ends with You are caught: N skips, score S. Landing exactly as the rope passes counts as a catch.
  • Quickening and joining: every 3 clears the period shortens by 0.125 s, from 1 s down to a floor of 0.625 s. Another skipper joins, up to 4, and each one adds 5 points to every later clear. The clear that triggers a join scores with the line as it stood.
  • Win: 12 clears ends the game with You win: N skips, score S.

Choices to check

  • The floor is 0.625 s, not 0.5 s. At 0.5 s the game would have been won before the floor was ever reached. With 0.625 s the floor is hit at clear 9, and the clamp is exercised at clears 12 and beyond.
  • Time is summed in floating point. The tests use times that are exact in binary (1/64 s, 1/16 s), so "however time is sliced" is checked exactly. That caveat is in a comment in rope.js.

Not done: no page, no catalogue entry and no dependencies, as the issue asked.

Try it: bun test skipping-rope/rope.test.mjs

🤖 Generated with Claude Code

Approved

Clean: pure rules module, no DOM/timers/random, ticks split at the exact pass time, refused calls return the same state, no input path or output to escape, no dependencies. Tests cover each rule and the measured time (54 ms) is stated. No page in this pull, as the issue asked.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs