P1.2: match detection (3+ horizontal/vertical runs)
Add a pure-sx match detector to the board model: `find_matches` walks each row and column once in maximal same-type spans and marks every cell in a run of length >= 3 into a `MatchMask` (a per-cell membership set mirroring Board.cells). Overlapping shapes (L / T where a horizontal and vertical run share a cell) collapse to the union automatically. `dump_matches` renders the set deterministically: matched cells show their gem char, others '.'. Detection only — no clear/collapse/refill (that is P2.1). tests/match_detect.sx exercises hand-crafted boards (built explicitly on a run-free checkerboard, no seeded init): a horizontal 3-run, a vertical 3-run, multiple disjoint runs, length-4 and length-5 runs, intersecting L and T shapes (shared cell counted once), and a no-match board. Output is locked as tests/expected/match_detect.stdout (+ .exit) and asserts matched-cell counts.
This commit is contained in:
1
tests/expected/match_detect.exit
Normal file
1
tests/expected/match_detect.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
109
tests/expected/match_detect.stdout
Normal file
109
tests/expected/match_detect.stdout
Normal file
@@ -0,0 +1,109 @@
|
||||
== horizontal-3 ==
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GORRROGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
--
|
||||
........
|
||||
........
|
||||
........
|
||||
..RRR...
|
||||
........
|
||||
........
|
||||
........
|
||||
........
|
||||
== vertical-3 ==
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOBOG
|
||||
GOGOGBGO
|
||||
OGOGOBOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
--
|
||||
........
|
||||
........
|
||||
.....B..
|
||||
.....B..
|
||||
.....B..
|
||||
........
|
||||
........
|
||||
........
|
||||
== disjoint-runs ==
|
||||
OGOGOGOG
|
||||
RRROGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGYG
|
||||
GOPPPOYO
|
||||
OGOGOGYG
|
||||
GOGOGOGO
|
||||
--
|
||||
........
|
||||
RRR.....
|
||||
........
|
||||
........
|
||||
......Y.
|
||||
..PPP.Y.
|
||||
......Y.
|
||||
........
|
||||
== len4-and-len5 ==
|
||||
OGOGOGOG
|
||||
GRRRRRGO
|
||||
OGOGOGOB
|
||||
GOGOGOGB
|
||||
OGOGOGOB
|
||||
GOGOGOGB
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
--
|
||||
........
|
||||
.RRRRR..
|
||||
.......B
|
||||
.......B
|
||||
.......B
|
||||
.......B
|
||||
........
|
||||
........
|
||||
== L-and-T ==
|
||||
OGOGOGOG
|
||||
GRRRGOGO
|
||||
OROGOGOG
|
||||
GRGOGOGO
|
||||
OGOGOGOG
|
||||
GOGYYYGO
|
||||
OGOGYGOG
|
||||
GOGOYOGO
|
||||
--
|
||||
........
|
||||
.RRR....
|
||||
.R......
|
||||
.R......
|
||||
........
|
||||
...YYY..
|
||||
....Y...
|
||||
....Y...
|
||||
== no-matches ==
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
--
|
||||
........
|
||||
........
|
||||
........
|
||||
........
|
||||
........
|
||||
........
|
||||
........
|
||||
........
|
||||
ok: match detection over hand-crafted boards
|
||||
Reference in New Issue
Block a user