feat(js): m04 random and spawn with fixtures and tests
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
2e39f23bb3
commit
08b462d5cc
@@ -0,0 +1,17 @@
|
||||
import { todo } from './todo.js'
|
||||
|
||||
/** Every board cell not covered by the snake, row-major (y outer loop, x inner loop). The apple does not count as occupied. */
|
||||
export const freeCells = (state) => todo('m04')
|
||||
|
||||
/**
|
||||
* Put an apple on a random free cell, drawing from `state.seed` (use `intBelow` and store the new seed).
|
||||
* Unchanged if there already is an apple or the status is not 'Playing'.
|
||||
* If no cell is free the board is full: status becomes 'Won' (seed unchanged, no apple).
|
||||
*/
|
||||
export const spawnApple = (state) => todo('m04')
|
||||
|
||||
/** One game step: `advance`, then make sure there is an apple. */
|
||||
export const tick = (state) => todo('m04')
|
||||
|
||||
/** A fresh game (`initialState`) with its first apple already placed. */
|
||||
export const newGame = (seed) => todo('m04')
|
||||
Reference in New Issue
Block a user