diff --git a/src/pipeline_import/transforms.py b/src/pipeline_import/transforms.py index 0695858..b1aff5d 100644 --- a/src/pipeline_import/transforms.py +++ b/src/pipeline_import/transforms.py @@ -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=}') diff --git a/tests/test_transforms.py b/tests/test_transforms.py index 0322201..5f61be0 100644 --- a/tests/test_transforms.py +++ b/tests/test_transforms.py @@ -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'