P2.1: clear matched cells (pure sx)
Add the first resolution-pipeline step to the headless board model.
- Introduce an `empty` hole sentinel on the Gem enum (ordinal 6, outside
GEM_COUNT so the RNG/pick_gem never draw it). board_dump renders holes as
EMPTY_CHAR ('.') via a single branch in gem_char, leaving boards without
holes byte-identical to before (existing goldens unchanged).
- clear_cells(board, mask): set every matched cell to `.empty`, leave all
others untouched, return the count cleared.
- clear_matches(board): detect+clear in one call; returns 0 (board unchanged)
when there are no matches.
No gravity or refill yet (P2.2 / P2.3).
tests/clear.sx applies detect->clear to hand-crafted boards (single
horizontal/vertical runs, disjoint runs, an overlapping L/T whose shared cell
clears once, and a no-match checkerboard), snapshots before/after, and asserts
matched cells became holes, non-matched cells are unchanged, and the cleared
count is exact. Locked as tests/expected/clear.{stdout,exit}.
This commit is contained in:
1
tests/expected/clear.exit
Normal file
1
tests/expected/clear.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
97
tests/expected/clear.stdout
Normal file
97
tests/expected/clear.stdout
Normal file
@@ -0,0 +1,97 @@
|
||||
== clear (detect -> clear) ==
|
||||
== horizontal-3 ==
|
||||
before:
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GORRROGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
after:
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GO...OGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
== vertical-3 ==
|
||||
before:
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOBOG
|
||||
GOGOGBGO
|
||||
OGOGOBOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
after:
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGO.OG
|
||||
GOGOG.GO
|
||||
OGOGO.OG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
== disjoint-runs ==
|
||||
before:
|
||||
OGOGOGOG
|
||||
RRROGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGYG
|
||||
GOPPPOYO
|
||||
OGOGOGYG
|
||||
GOGOGOGO
|
||||
after:
|
||||
OGOGOGOG
|
||||
...OGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOG.G
|
||||
GO...O.O
|
||||
OGOGOG.G
|
||||
GOGOGOGO
|
||||
== L-and-T ==
|
||||
before:
|
||||
OGOGOGOG
|
||||
GRRRGOGO
|
||||
OROGOGOG
|
||||
GRGOGOGO
|
||||
OGOGOGOG
|
||||
GOGYYYGO
|
||||
OGOGYGOG
|
||||
GOGOYOGO
|
||||
after:
|
||||
OGOGOGOG
|
||||
G...GOGO
|
||||
O.OGOGOG
|
||||
G.GOGOGO
|
||||
OGOGOGOG
|
||||
GOG...GO
|
||||
OGOG.GOG
|
||||
GOGO.OGO
|
||||
== no-matches ==
|
||||
before:
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
after:
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
ok: clear over hand-crafted boards
|
||||
Reference in New Issue
Block a user