Add the settle loop a swap triggers: resolve(board) runs rounds of
detect -> clear -> collapse -> refill until a round finds no match,
returning a Cascade { depth, cleared } so P3 can read per-round
cleared-cell counts and the combo-driving depth. resolve_step exposes
one round. Termination follows from eventually reaching no-match; no
artificial round cap.
tests/cascade.sx: a fixed-seed hand-crafted board where clearing the
initial BBB lets gravity pack col 0 into a fresh vertical RRR, so the
loop chains two rounds; snapshots each per-round board and the final
depth, asserts the final board is stable and that public resolve
reproduces the manual loop, plus a depth-0 control on an unchanged
checkerboard. Locked in tests/expected/cascade.{stdout,exit}.
31 lines
360 B
Plaintext
31 lines
360 B
Plaintext
== cascade (resolution loop) ==
|
|
start:
|
|
OGOGOGOG
|
|
GOGOGOGO
|
|
RGOGOGOG
|
|
BBBOGOGO
|
|
RGOGOGOG
|
|
ROGOGOGO
|
|
OGOGOGOG
|
|
GOGOGOGO
|
|
round 1: cleared 3 cells
|
|
RBRGOGOG
|
|
OGOOGOGO
|
|
GOGGOGOG
|
|
RGOOGOGO
|
|
RGOGOGOG
|
|
ROGOGOGO
|
|
OGOGOGOG
|
|
GOGOGOGO
|
|
round 2: cleared 3 cells
|
|
RBRGOGOG
|
|
PGOOGOGO
|
|
YOGGOGOG
|
|
RGOOGOGO
|
|
OGOGOGOG
|
|
GOGOGOGO
|
|
OGOGOGOG
|
|
GOGOGOGO
|
|
cascade depth 2
|
|
ok: cascade resolves to a stable board
|