Skip to content

Latest commit

 

History

History
71 lines (56 loc) · 2.88 KB

File metadata and controls

71 lines (56 loc) · 2.88 KB

Game reference

Every game exposes move.state as a plain, JSON-serializable object. Below is each game's game= token(s), where its state lives, and the state shape. Full inline docs are at the top of each module in src/games/.

friendly name token(s) state carried in
pool (8-ball) pool, pool2, pool3 replay
darts darts replay
mini_golf golf replay
connect4 connect replay
archery archery replay
basketball basketball replay (+ replay2/3/4)
cup_pong beer replay
sea_battle sea envelope + replay
word_hunt hunt envelope
anagrams anagrams envelope
wordbites wordbites envelope

state shapes

// pool  — 8-ball. num: 0=cue, 1-7 solids, 8=eight, 9-15 stripes; pocketed = alpha<1
{ shot: { d, x, y, power, spin },
  initial: Ball[], final: Ball[], segments: Ball[][], stripes: number }
// Ball = { x, y, rot, alpha, num, vx, vy, vz, pocketed }

// darts  — mult: 0=single, 2=double, 3=triple (scores count down from mode)
{ scores: [A, B], scores_end: [A, B],
  throws: [{ index, x, y, points, segment, mult, ring }] }

// mini_golf  — one entry per shot, grouped by hole; shot = {power, angle}
{ holes: Shot[][], opponent_holes: Shot[][] }

// connect4  — 7x6, row-major; board is BEFORE the move (move cell empty)
{ cells: number[], cols: 7, rows: 6, grid: number[][],
  move: { col, row, player } | null }
// render(state) -> ASCII board

// archery  — 5-int state before/after; each throw = {player, x, y, z}
{ state_before: number[], state_after: number[], throws: [{ player, x, y, z }] }

// basketball  — shot = {t, arc, spin, made}; extra = other shot sets (read-only)
{ shots: [{ t, arc, spin, made }], extra: { replay2, replay3, replay4 } }

// cup_pong  — cups = indices still standing (0-9); path records kept verbatim
{ board_start: { cups1, cups2 }, board_end: { cups1, cups2 },
  throws: [{ records: string[], status: number|null, markers: number[] }] }
// or { raw } for a non-canonical replay

// sea_battle  — ship = {pos:[x,y], hits:number[], rot}; bullets = flat 0/1 grid
{ size, shots: [[c, r]], last_shot: [c, r] | null,
  ships1: Ship[], ships2: Ship[], bullets1: number[], bullets2: number[] }
// to_env(state) re-encodes ships1/ships2

// word_hunt  — grid letters (16 => 4x4)
{ letters, grid: string[][], lang,
  players: [{ score, count, words: string[] }], winner }

// anagrams  — letter pool
{ letters, lang, players: [{ score, count, words: string[] }], winner }

// wordbites  — tile pieces + word lists
{ letters, lang, pieces: [{ orient, x, y, letters }],
  players: [{ score, count, words: string[] }], winner }

Games whose state lives in the envelope (sea_battle, word_*) also export a to_env(state) that re-encodes those fields; the reply's envelope carries them through automatically.