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
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.
-
Reviews
ApprovedMatches issue #105: two new files only, pure rules, seeded scatter (no Math.random), window.Shy / import dual loading like the other rules files, no index.html and no shared files touched. Tests cover the square window, wobble then fall, bonus ball, posts moving back, and win/loss at 9, and throwBall leaves its input untouched. Nothing here is user-facing yet (no page, no terminal door), which is what the issue asked for. Next, I would: (1) in the page issue, give the aim controls keyboard and touch-friendly inputs and announce the
linetext and each throw result in an aria-live region, so the game is playable without a mouse and with a screen reader; (2) credit the traditional fairground game in the page and README when it lands, and add the README entry then. -
Checks
shipped production is serving it deploy ab54f53
-
History
- Add Coconut Shy rules: a tested coconut-shy/shy.js that plays a whole game from plain data (#105) e7b7810
- Add Tug of War: pull in rhythm with your team to drag the rope's ribbon over your line at the village fete (#97) 97bb230
- Add Sheepdog: guide the flock through the gate and into the pen before the light goes (#93) 6f1ec61
- Add Firefly Jar: tap the glowing fireflies into a jar on a summer night before the moths put the lantern out (#90) 6db3d65
- From the app: pressing and holding i. mobile keeps highlighting and adding the iphone magni... (#89) de8d11a
- Playtests: a scripted round per game that reaches a win or a loss (#70) 89b614c
- Add Soapbox Derby: steer a wooden cart down a cobbled hill between the hay bales (#80) 4512fea
- Add Signal Box: repeat the lever sequence to route each train through a country junction (#79) 6436bd8
- Add Espresso Bar: pour each coffee to the line as cups slide past under the spout (#71) 50e7872
- Add Wood Split: split logs on a chopping block by bringing the axe down on the crack (#67) 553ae24
- Add Goalkeeper: dive left or right to save ten penalties in a village football ground (#75) 8b54ed6
- Add Bell Tower: ring the peal back on four bells, one bell longer each round (#69) 8a3ca29
- Add Archery: ten arrows at a straw target, reading the wind off a pennant (#64) 8327827
- Add Tram Line: drive a city tram and stop each door on the yellow mark (#63) cf817a1
- Add Tightrope: walk a wire between two rooftops, leaning to keep your balance in the wind (#60) 93e1bbc
- games need to have a much higher playability standard. tests that actually pl… (#49) 8c0d92c
- Add Ice Fishing: drop a line through the ice and reel each fish up before the line snaps (#58) 07375f1
- Add Bread Oven: slide loaves into a wood-fired oven and pull each one out golden (#54) 9c2022a
- Add Beekeeper: smoke the hive calm and lift out honey frames before the bees swarm (#53) fd12dfd
- Add Campfire: keep the fire burning through the night by feeding it the right logs (#52) db506c3
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),nextRoundandagain. The state exposesphase(aim,betweenorover),round,ballsLeft,down,best,over,outcome(wonorlost) and alineof text. A playtest can script a round from those. - Loading:
shy.jsloads aswindow.Shyfrom a<script>tag and byimportin the tests, the same waysoapbox-derby/cart.jsdoes.
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
I added the Coconut Shy rules as two new files,
coconut-shy/shy.jsandcoconut-shy/shy.test.mjs.bun test coconut-shy/passes with 14 tests. I did not see a fullbun testfinish: 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 --noEmitonly printed its help text because the repo has no tsconfig, so there was no type check. I also did not runscripts/gate.tsorscripts/fast.ts; neither exists in this clone.How the rules work
Math.random.newGame,throwBall(returns{state, event}and leaves the state you pass in untouched),nextRoundandagain. The state exposesphase(aim,betweenorover),round,ballsLeft,down,best,over,outcome(wonorlost) and alineof text. A playtest can script a round from those.shy.jsloads aswindow.Shyfrom a<script>tag and byimportin the tests, the same waysoapbox-derby/cart.jsdoes.Choices and gaps
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