From 2bc394aba70975dae69e0b7184b3247c1ee5c2bb Mon Sep 17 00:00:00 2001 From: SaridakisStamatisChristos <34583142+SaridakisStamatisChristos@users.noreply.github.com> Date: Tue, 7 Oct 2025 15:26:58 +0300 Subject: [PATCH] Add simple coloring metadata regression tests --- tests/test_strategies_extras.py | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/test_strategies_extras.py b/tests/test_strategies_extras.py index 0503c09..0ed9d6b 100644 --- a/tests/test_strategies_extras.py +++ b/tests/test_strategies_extras.py @@ -38,3 +38,52 @@ def test_simple_coloring_one_elimination() -> None: assert move["strategy"] == "simple_coloring" assert move["digit"] == digit assert digit not in cand[move["r"]][move["c"]] + + +def test_simple_coloring_reports_row_conflict_metadata() -> None: + grid = [[0] * 9 for _ in range(9)] + cand = candidates(grid) + digit = 4 + + for r in range(9): + for c in range(9): + cand[r][c].discard(digit) + + # Build a coloring component where two same-colored nodes share row 1. + # Row 1 contains three candidates so no conjugate link is created there. + pattern = [(1, 1), (4, 1), (4, 7), (2, 7), (1, 8), (1, 4)] + for r, c in pattern: + cand[r][c].add(digit) + + move = apply_simple_coloring(grid, cand) + assert move is not None + assert move["strategy"] == "simple_coloring" + assert move["digit"] == digit + assert move["unit"] == "row" + assert move["unit_index"] == 1 + assert (move["r"], move["c"]) == (1, 1) + assert digit not in cand[1][1] + + +def test_simple_coloring_reports_column_conflict_metadata() -> None: + grid = [[0] * 9 for _ in range(9)] + cand = candidates(grid) + digit = 6 + + for r in range(9): + for c in range(9): + cand[r][c].discard(digit) + + # Analogous setup forcing two same-colored nodes to appear in column 1. + pattern = [(1, 1), (1, 4), (7, 4), (7, 2), (8, 1), (4, 1)] + for r, c in pattern: + cand[r][c].add(digit) + + move = apply_simple_coloring(grid, cand) + assert move is not None + assert move["strategy"] == "simple_coloring" + assert move["digit"] == digit + assert move["unit"] == "col" + assert move["unit_index"] == 1 + assert (move["r"], move["c"]) == (1, 1) + assert digit not in cand[1][1]