Skip to content

Commit

Permalink
fix stalemate issue
Browse files Browse the repository at this point in the history
  • Loading branch information
guidopetri committed Aug 26, 2024
1 parent 3b004ab commit df80a98
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/pipeline_import/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def get_sf_evaluation(fen: str,
rating = 9999
else:
rating = -9999
elif board.is_stalemate():
rating = 0
else:
raise ValueError('No best move found and not a checkmate position '
f'for: {fen=} {sf.info=}')
Expand Down
15 changes: 15 additions & 0 deletions tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,21 @@ def test_get_sf_evaluation_checkmate_white():
assert rating == 9999


def test_get_sf_evaluation_in_stalemate():

fen = '3Q4/8/8/8/8/3QK2P/8/4k3 b - - 0 56'

cfg = ConfigParser()
cfg.read('luigi.cfg')
stockfish_loc = cfg['stockfish_cfg']['location']

depth = 20

rating = transforms.get_sf_evaluation(fen, stockfish_loc, depth)

assert rating == 0


def test_get_sf_evaluation_in_checkmate():

fen = '4Rb1k/7Q/8/1p4N1/p7/8/1P4PK/8 b - - 4 0'
Expand Down

0 comments on commit df80a98

Please sign in to comment.