Skip to content

Commit

Permalink
Merge pull request #1117 from mooskagh/movesleft
Browse files Browse the repository at this point in the history
Add 'movesleft' parameter to UCI info parsing
  • Loading branch information
niklasf authored Oct 27, 2024
2 parents 100b1c8 + f1676d5 commit d625be1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion chess/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1771,7 +1771,8 @@ def _parse_uci_info(arg: str, root_board: chess.Board, selector: Info = INFO_ALL
if parameter == "string":
info["string"] = remaining_line
break
elif parameter in ["depth", "seldepth", "nodes", "multipv", "currmovenumber", "hashfull", "nps", "tbhits", "cpuload"]:
elif parameter in ["depth", "seldepth", "nodes", "multipv", "currmovenumber",
"hashfull", "nps", "tbhits", "cpuload", "movesleft"]:
try:
number, remaining_line = _next_token(remaining_line)
info[parameter] = int(number) # type: ignore
Expand Down
5 changes: 3 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3508,14 +3508,15 @@ def test_uci_info(self):
self.assertEqual(info["seldepth"], 8)
self.assertEqual(info["score"], chess.engine.PovScore(chess.engine.Mate(+3), chess.WHITE))

# Info: tbhits, cpuload, hashfull, time, nodes, nps.
info = chess.engine._parse_uci_info("tbhits 123 cpuload 456 hashfull 789 time 987 nodes 654 nps 321", board)
# Info: tbhits, cpuload, hashfull, time, nodes, nps, movesleft.
info = chess.engine._parse_uci_info("tbhits 123 cpuload 456 hashfull 789 movesleft 42 time 987 nodes 654 nps 321", board)
self.assertEqual(info["tbhits"], 123)
self.assertEqual(info["cpuload"], 456)
self.assertEqual(info["hashfull"], 789)
self.assertEqual(info["time"], 0.987)
self.assertEqual(info["nodes"], 654)
self.assertEqual(info["nps"], 321)
self.assertEqual(info["movesleft"], 42)

# Hakkapeliitta double spaces.
info = chess.engine._parse_uci_info("depth 10 seldepth 9 score cp 22 time 17 nodes 48299 nps 2683000 tbhits 0", board)
Expand Down

0 comments on commit d625be1

Please sign in to comment.