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

Migrated from github.com/amirmushichge/pixel-plays

Coconut Shy rules: a tested `coconut-shy/shy.js` that plays a whole game from plain data #119

opened this

Merged 30d 21h ago, live in production

I added the Coconut Shy rules as two new files, coconut-shy/shy.js and coconut-shy/shy.test.mjs. bun test coconut-shy/ passes with 14 tests. I did not see a full bun test finish: it hit the sandbox's 120 s limit and I pushed anyway, so the forge's check is the first full run.

Notes

opened this

I added the Coconut Shy rules as two new files, coconut-shy/shy.js and coconut-shy/shy.test.mjs. bun test coconut-shy/ passes with 14 tests. I did not see a full bun test finish: it hit the sandbox's 120 s limit and I pushed anyway, so the forge's check is the first full run. bun x tsc --noEmit only printed its help text because the repo has no tsconfig, so there was no type check. I also did not run scripts/gate.ts or scripts/fast.ts; neither exists in this clone.

How the rules work

  • Throw and landing: a throw is a power (0 to 1) and an angle. The ball lands at v²·sin(2a)/g metres, with v = power × 14 m/s, plus a seed-driven drift of at most 5 cm. There is no Math.random.
  • Hits: the square window is 40% of the coconut's width (0.24 m of 0.6 m). A hit inside it knocks the coconut off. A hit elsewhere on the coconut wobbles it, and a second wobble makes it fall.
  • Round and bonus ball: a round is five balls. If every coconut is down, there is one bonus ball on a fresh rack, and the first rack's five stay in the score.
  • Posts and game end: the posts start at 6 m and move 2 m back each round. A game is three rounds. It is over after round three, with a win at 9 or more down and a loss below.
  • State for the page: newGame, throwBall (returns {state, event} and leaves the state you pass in untouched), nextRound and again. The state exposes phase (aim, between or over), round, ballsLeft, down, best, over, outcome (won or lost) and a line of text. A playtest can script a round from those.
  • Loading: shy.js loads as window.Shy from a <script> tag and by import in the tests, the same way soapbox-derby/cart.js does.

Choices and gaps

  • One-dimensional model: I modelled the line of posts as one dimension, with five coconuts 1.5 m apart along the throw.
  • Bonus ball: I read "bonus ball when every coconut is down" as a single bonus ball, granted once per round after the fifth ball, with no second bonus after it.
  • Window size: I chose 40%, above the third the issue asks for as a minimum.
  • Left alone: there is no index.html, and I changed nothing shared (shell.js, index.html, README.md, serve.test.mjs, rounds.mjs, og/).

To try it: bun test coconut-shy/.

🤖 Generated with Claude Code

Closes #105

commented

I added the Coconut Shy rules as two new files, coconut-shy/shy.js and coconut-shy/shy.test.mjs. bun test coconut-shy/ passes with 14 tests. I did not see a full bun test finish: it hit the sandbox's 120 s limit and I pushed anyway, so the forge's check is the first full run. bun x tsc --noEmit only printed its help text because the repo has no tsconfig, so there was no type check. I also did not run scripts/gate.ts or scripts/fast.ts; neither exists in this clone.

How the rules work

  • Throw and landing: a throw is a power (0 to 1) and an angle. The ball lands at v²·sin(2a)/g metres, with v = power × 14 m/s, plus a seed-driven drift of at most 5 cm. There is no Math.random.
  • Hits: the square window is 40% of the coconut's width (0.24 m of 0.6 m). A hit inside it knocks the coconut off. A hit elsewhere on the coconut wobbles it, and a second wobble makes it fall.
  • Round and bonus ball: a round is five balls. If every coconut is down, there is one bonus ball on a fresh rack, and the first rack's five stay in the score.
  • Posts and game end: the posts start at 6 m and move 2 m back each round. A game is three rounds. It is over after round three, with a win at 9 or more down and a loss below.
  • State for the page: newGame, throwBall (returns {state, event} and leaves the state you pass in untouched), nextRound and again. The state exposes phase (aim, between or over), round, ballsLeft, down, best, over, outcome (won or lost) and a line of text. A playtest can script a round from those.
  • Loading: shy.js loads as window.Shy from a <script> tag and by import in the tests, the same way soapbox-derby/cart.js does.

Choices and gaps

  • One-dimensional model: I modelled the line of posts as one dimension, with five coconuts 1.5 m apart along the throw.
  • Bonus ball: I read "bonus ball when every coconut is down" as a single bonus ball, granted once per round after the fifth ball, with no second bonus after it.
  • Window size: I chose 40%, above the third the issue asks for as a minimum.
  • Left alone: there is no index.html, and I changed nothing shared (shell.js, index.html, README.md, serve.test.mjs, rounds.mjs, og/).

To try it: bun test coconut-shy/.

🤖 Generated with Claude Code

Sign in to join this conversation.

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

Keyboard shortcuts

Docs