Expand description
Headless game simulation. No engine types allowed in this module tree.
Structs§
- Board
- The entire game state. No engine types, no floats, no hash maps: every tick is a pure function of prior state plus one action per seat, so the same seed and input list replays bit-identically on any platform.
- Crab
- One crab. Position is integer-only: the crab is
progresssubunits past the centre oftile, moving toward the centre of the next tile indir.prev_*hold last tick’s position for render-side interpolation (spec §7.4) and are never read by the simulation itself. - Gull
- One gull. Moves on the grid exactly like a crab while walking (walls, signposts, handedness), slower than a common crab.
- Input
Msg - A message to put on the wire: this player’s action for a future frame.
8 bytes packed via
InputMsg::encode. - Level
- Lockstep
- Transport-agnostic lockstep state machine for one peer.
- Pcg32
- Minimal PCG32 (XSH-RR 64/32): the
Board’s seeded, deterministic PRNG. - Replay
- Signpost
- Spawner
Enums§
- BotLevel
- Bot difficulty. Levels differ in reaction cadence and search radii; Hard additionally plays offense, steering gulls at the leading rival’s castle. All levels stay pure functions of the board.
- CapPolicy
- What happens when a player places a signpost at their cap.
- Crab
Kind - Direction
- A grid direction in screen space: row 0 is the top of the board, so
Updecreasesy. “Left of” and “right of” are from the walking agent’s point of view (facingUp, the agent’s left isLeft). - Effort
- How hard a search may work before it admits defeat.
- Goal
- What a stage asks of the player.
AllCrabsis classic puzzle mode; the rest are Beach Day challenge goals (the original’s Stage Challenge, re-themed). - Gull
State - Gull behaviour state (spec §3.5). Walking is the default and the whole offensive layer: a walking gull is steerable with signposts. Flight is a brief, occasional hop that exists so no corner can be permanently safe.
- Handedness
- Which claw is oversized, i.e. which side this crab tries first when its forward path is blocked. The one-bit divergence from ChuChu Rocket that turns herding puzzles into sorting puzzles (spec §2).
- Level
Kind - What a level was built to be.
- Player
Action - One player’s input for one tick. Coordinates are the cursor’s tile. The
wire packs this into 2 bytes (spec §7.6); see
crate::transport. - Puzzle
Outcome - Signpost
Health - Solve
Outcome - What a search found, and when it found nothing, whether that is a proof.
- Tide
Event - The sparkling crab’s roulette (the original’s “?”-mouse events, re-themed for the beach).
- Tile
Kind
Constants§
- DEFAULT_
DELAY - Input delay in frames: 3 at 30 Hz = 100 ms, the spec’s 2–3 frame range.
- DEFAULT_
NODE_ BUDGET - Boards a budgeted search may simulate before it gives up.
- EVENT_
TICKS - Tide-event durations (manias, tempo shifts): 10 s.
- HASH_
INTERVAL - How often peers exchange state hashes for desync detection.
- INPUT_
BYTES - Bytes an
InputMsgoccupies on the wire. - LURE_
TICKS - Molting-crab lure duration: 10 s at 30 Hz (spec §3.2).
- MAX_
PLAYERS - Seats a board can hold. Six is the current cut: four corners and two
long-edge castles on a generated arena (see
castle_spots). The handcrafted classic arena is a four-castle beach and stays one. - MAX_
SIGNPOSTS_ PER_ PLAYER - Spec §3.3: placing a fourth signpost removes that player’s oldest.
- PUZZLE_
TICK_ LIMIT - Sim ticks a puzzle may run before it counts as failed (60 s at 30 Hz). Generous: it exists to catch crabs orbiting forever, not to add pressure.
- SIGNPOST_
LIFETIME - Versus signposts fade away after this many ticks (10 s, the original’s balance valve against stale fortifications). Puzzle-rule boards (CapPolicy::Reject) keep posts forever: a fixed inventory implies permanence.
- SPILL_
CAP - Most live crabs a single castle hit can spill back onto the sand. The score still drops a full tier (spec §3.4’s legible loss); crabs beyond the cap are lost to the flock rather than flooding the board.
- SUBUNITS_
PER_ TILE - Spec §4.2: one tile is 256 subunits; all movement is integer arithmetic.
- SURGE_
TICKS - The final-scramble threshold: with a round timer set, gull spawning doubles in rate when this many ticks remain (spec §3.6: 30 s).
- TICKS_
PER_ SECOND - The canonical simulation rate. Everything that converts ticks to seconds (round lengths, clocks, speed settings) goes through this.
- TIER_
FLOORS - Castle tier thresholds by banked score (spec §3.4).
Functions§
- bot_
action - What the bot wants to do this tick, and whether its hand could get there in time to do it.
- campaign_
levels - Parse the whole campaign. Panics on a malformed level; the validation test fails first, so a shipped binary never hits this.
- castle_
spots - A castle spot per seat for a board of the given size.
- castle_
tier - Castle tier (0–3) for a banked-crab score.
- challenge_
levels - classic_
arena - The handcrafted Turf War arena for 2-4 seats: a corner castle per player,
two side spawners feeding the middle, rocks to route around, gulls on a
timer, and a 3-minute tide.
preload_scoresstocks two castles for sandbox screenshots. - classic_
arena_ seeded - The classic layout on an arbitrary PRNG seed. The layout is identical; only the in-round random stream (spawn kinds, gull entry points, events) differs. Online play uses the canonical seed so peers agree by construction; local play may vary it for round-to-round freshness.
- decode_
action - encode_
action - Pack an action for the wire: byte 0 is the cursor column, byte 1 the row,
byte 2 is op (bits 0-1: 0 none, 1 place, 2 remove) and direction
(bits 2-3, as
Direction::id). - generate_
arena - Generate a versus arena for
seatsplayers (2–MAX_PLAYERS) from a seed, at any size from 9×7 up. - solve
- Search for a signpost set (within the level’s inventory) that meets the
level’s goal, under
DEFAULT_NODE_BUDGET. Prefers fewer posts. - solve_
with solve, with the ceiling named by the caller.- validate
- Convenience: validate a level exhaustively, returning the solution found (also checks an authored level’s claim that it is solvable).