Skip to content

Commit

Permalink
Make initial sanity check more general
Browse files Browse the repository at this point in the history
  • Loading branch information
miguel-ambrona committed Jan 24, 2024
1 parent bf37e08 commit 62796e2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/deadpos.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,15 @@ def main():
words = line.split(">>=")
fen = words[0].strip()

fen_board = fen.split(" ")[0]
if not chess.Board(fen_board + " w - - 0 1").is_valid() and \
not chess.Board(fen_board + " b - - 0 1").is_valid():
fen_parts = fen.split(" ")
fen_board = fen_parts[0]
valid = False
for turn in fen_parts[1].replace("?", "w b").split(" "):
if chess.Board(fen_board + " " + turn + " - - 0 1").is_valid():
valid = True
break

if not valid:
print("Invalid FEN")
continue

Expand Down

0 comments on commit 62796e2

Please sign in to comment.