Files
functional-programming-snake/js/src/spawn.js
T
2026-10-28 23:42:36 +01:00

18 lines
769 B
JavaScript

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')