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

Migrated from github.com/amirmushichge/pixel-plays

Bumper Cars rules: a tested `bumper-cars/floor.js` where you steer a car on a walled floor and shove three seeded rivals into the wall without a head-on bump, from plain data, in a two-file pull with a test file that runs in under a second #320

shipped production is serving it opened this has it
opened this

A new Arcade game for the catalogue. A fairground bumper-car floor is a grid ringed by a rubber wall. You steer one car, and three rival cars move by a seeded pattern. Bumping a rival from behind or the side shoves it one square, and shoving it into the wall scores. A head-on bump costs you a life. Rules only: no page and no catalogue entry yet.

Done looks like:

Files: bumper-cars/floor.js, bumper-cars/floor.test.mjs: a two-file pull. Risk: none outside the folder. Do not touch shell.js, index.html, town.js, rounds.mjs, forge.json, scripts/, playtest.test.mjs or serve.test.mjs here. Fits: a builder.

commented

Reviewed pull #336 at its head: ticked bumper-cars/floor.js holds the rules as plain data in, plain data out, with no DOM. start(seed) gives a floor of stated size, your car's start square and heading, three rivals with seeded start squares, headings and turn patterns, a stated number of lives and a round of a stated number of ticks. Randomness comes only from the seed, so the same seed and inputs give the same round; no timers and no Math.random.; steer(state, turn) sets your next turn: left, right or straight. It refuses an unknown turn or a round already over with a reason, and a refused call returns the same state. step(state) moves every car one square in a stated order. A car that would leave the floor stops at the wall and turns.; Bumps: moving into a rival's back or side shoves it one square the way you were going. A rival shoved into the wall scores a stated amount and is then placed at a seeded free square. Meeting a rival head-on costs a life. The round ends with a loss line when lives run out, or with a win line that reports the score and the wall shoves when the ticks run out.; bumper-cars/floor.test.mjs asserts each rule above: the same seed gives the same rivals and the same round; a wall stop and turn; a side bump and a back bump shoving one square; a shove into the wall scoring and the rival being placed again; a head-on bump costing a life; each refusal with its reason; the loss line; and the win line.; bun test passes for the new file.; bumper-cars/floor.test.mjs loads no page and starts no renderer or server: it calls the rules module directly and runs in under one second on its own (bun test bumper-cars/floor.test.mjs). The pull states the measured time.; If the check fails only on "test took longer than 600s" or a CPU limit, the pull says so. Do not cut the rules or their tests to get under the limit..

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs