fix handling of walls, add unit test

This commit is contained in:
Andreas Koepf 2025-02-14 23:29:17 +01:00
parent 8ff82bb5a6
commit a5d784c6ef
2 changed files with 59 additions and 32 deletions

View file

@ -89,3 +89,20 @@ def test_perform_moves():
solution = "E-1 H-3 A-1 J+1 C-3 M+1 B+1 K-4 A+1 C+2 D-1 F-1 H+3 A-1 K+1 B-1 M-1 C+1 J-1 E+1 G+3 A-1 I+1 B-3 I-1 A+1 G-1 E-1 J+1 C-1 K-1 L-1 M+3 A+3"
b.perform_moves(solution)
assert b.solved
def test_perform_moves_walls():
b = Board("BBoIKxCCCIKoGAAJooGoHJDDooHEELoFFoxL")
print(b.board_str())
# assert sum(1 for p in b._pieces if p.fixed) == 2, "two walls expected"
# assert not b.solved
# b.perform_moves(
# "F-1 G+1 A-1 H-1 E-2 J+2 D-1 L-3 D+1 J-2 E+3 H+2 A+1 J+2 D-3 I+2 K+2 B+3 L+1 C+3 G-3 A-1 D-1 H-4 A+1 D+1 F+1 G+4 A-1 D-1 H+2 B-2"
# )
# assert not b.solved
# b.perform_moves(
# "C-3 I-2 J-2 E-3 J+2 I+2 B+2 C+3 H-2 A+1 D+1 G-4 A-1 D-1 E-1 F-1 H+4 A+1 B-2 D+1 G+2 C-3 I-2 K-2 L+1 A+3"
# )
# assert b.solved