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

Migrated from github.com/amirmushichge/pixel-plays

Welly Toss rules: a tested `welly-toss/throw.js` where you swing a boot and let go at the right moment of the arc to land it past the marker flags, against a seeded crosswind, from plain data, in a two-file pull with a test file that runs in under a second #323

opened this

Merged 33d 6h ago, live in production

This adds the Welly Toss rules as welly-toss/throw.js plus welly-toss/throw.test.mjs. There is no page and no catalogue entry, and nothing outside the folder is touched. Tests: bun test welly-toss/throw.test.mjs gives 9 pass, 0 fail, and the run took 45 ms, measured here.

Notes

opened this

This adds the Welly Toss rules as welly-toss/throw.js plus welly-toss/throw.test.mjs. There is no page and no catalogue entry, and nothing outside the folder is touched.

Tests: bun test welly-toss/throw.test.mjs gives 9 pass, 0 fail, and the run took 45 ms, measured here. The test file calls the rules module directly and loads no page, renderer or server. bun x tsc --noEmit only printed its help text, so type checking did not run. The repo has no scripts/gate.ts, so I did not run it.

Rules

  • Setup: start(seed) draws five crosswinds from the seed, each within ±4 m/s to 0.1. The side lines are at ±5 m and the flags at 10, 20, 30 and 40 m. The same seed gives the same contest.
  • Swing: step(state) advances the swing one tick. The period is 60 ticks (3 s) and the amplitude is 65°. It also lands a flight in the air when its time is up. After a landing the swing restarts, or the contest ends after the fifth.
  • Release: release(state) lets go at the current tick, with launch angle and speed taken from the swing phase. Flight is projectile motion over flat ground:
    • Distance is d = v²·sin2α/g.
    • Drift is 0.3·wind·flight time.
  • Fouls: A backswing release is a foul. So is drifting past ±5 m. Releasing while the arm points downward drops the boot at your feet for 0 m, which is not a foul.
  • Best phase: BEST_TICK is the forward-swing tick that lands furthest in still air. The module finds it once from the formulas when it loads, rather than hard-coding it, and the test checks it against every forward tick.
  • Refusals: release returns {ok:false, state, why} with the same state object during a flight and after the fifth throw.
  • End: the score is the sum of the best three non-foul distances. The end line reads Final: <score> m from the best 3 of 5 throws; furthest flag <n> m, or none reached.

Choices

  • Release resolves the landing immediately and stores it in the state. The throw is only recorded when step runs the flight out. That is what makes a release during a flight refusable.
  • I did not add drag, air resistance or a launch height, and the wind moves the boot sideways only, never along the throw.

Closes #309

commented

This adds the Welly Toss rules as welly-toss/throw.js plus welly-toss/throw.test.mjs. There is no page and no catalogue entry, and nothing outside the folder is touched.

Tests: bun test welly-toss/throw.test.mjs gives 9 pass, 0 fail, and the run took 45 ms, measured here. The test file calls the rules module directly and loads no page, renderer or server. bun x tsc --noEmit only printed its help text, so type checking did not run. The repo has no scripts/gate.ts, so I did not run it.

Rules

  • Setup: start(seed) draws five crosswinds from the seed, each within ±4 m/s to 0.1. The side lines are at ±5 m and the flags at 10, 20, 30 and 40 m. The same seed gives the same contest.
  • Swing: step(state) advances the swing one tick. The period is 60 ticks (3 s) and the amplitude is 65°. It also lands a flight in the air when its time is up. After a landing the swing restarts, or the contest ends after the fifth.
  • Release: release(state) lets go at the current tick, with launch angle and speed taken from the swing phase. Flight is projectile motion over flat ground:
    • Distance is d = v²·sin2α/g.
    • Drift is 0.3·wind·flight time.
  • Fouls: A backswing release is a foul. So is drifting past ±5 m. Releasing while the arm points downward drops the boot at your feet for 0 m, which is not a foul.
  • Best phase: BEST_TICK is the forward-swing tick that lands furthest in still air. The module finds it once from the formulas when it loads, rather than hard-coding it, and the test checks it against every forward tick.
  • Refusals: release returns {ok:false, state, why} with the same state object during a flight and after the fifth throw.
  • End: the score is the sum of the best three non-foul distances. The end line reads Final: <score> m from the best 3 of 5 throws; furthest flag <n> m, or none reached.

Choices

  • Release resolves the landing immediately and stores it in the state. The throw is only recorded when step runs the flight out. That is what makes a release during a flight refusable.
  • I did not add drag, air resistance or a launch height, and the wind moves the boot sideways only, never along the throw.
commented

The side-line foul can now happen in a contest from start(seed). I retuned the numbers, rewrote the tests you flagged, and pushed to the same branch. bun test welly-toss/throw.test.mjs gives 9 pass, 0 fail in 49 ms.

Retune (welly-toss/throw.js)

  • WIND_DRAG is now 0.6 and SIDE is now 3 m. The wind range is unchanged at ±4 m/s.
  • A best-phase throw drifts about 1.25 m per m/s of wind. Winds up to about 2.4 m/s keep it inside the lines, and stronger winds foul it.

Tests (welly-toss/throw.test.mjs)

  • The side-line test no longer passes a wind of 8 m/s. It searches seeds 0–199 for one whose first wind fouls the best-phase throw and one whose first wind keeps it clean.
  • It then plays both through start(seed) and toss, and checks that the fouling wind is within ±4 m/s.
  • The seeded-wind test now takes the min and max over 200 seeds. It requires both to come within 10% of ±WIND_MAX, and it checks every wind is within the range.
  • The end-line test now compares against fixed numbers worked by hand: distances 33.54, 0, 1.7, 0 and 33.54, and a score of 68.78. It no longer recomputes the score.
  • The wind-drift test used a 3 m/s wind, which now fouls, so I changed it to ±2 m/s.

tsc: the repo has no tsconfig.json or package.json. bun x tsc --noEmit only prints its help text, so type checking cannot run here.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs