Skip to content

Commit d625be1

Browse files
authored
Merge pull request niklasf#1117 from mooskagh/movesleft
Add 'movesleft' parameter to UCI info parsing
2 parents 100b1c8 + f1676d5 commit d625be1

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

chess/engine.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,8 @@ def _parse_uci_info(arg: str, root_board: chess.Board, selector: Info = INFO_ALL
17711771
if parameter == "string":
17721772
info["string"] = remaining_line
17731773
break
1774-
elif parameter in ["depth", "seldepth", "nodes", "multipv", "currmovenumber", "hashfull", "nps", "tbhits", "cpuload"]:
1774+
elif parameter in ["depth", "seldepth", "nodes", "multipv", "currmovenumber",
1775+
"hashfull", "nps", "tbhits", "cpuload", "movesleft"]:
17751776
try:
17761777
number, remaining_line = _next_token(remaining_line)
17771778
info[parameter] = int(number) # type: ignore

test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3508,14 +3508,15 @@ def test_uci_info(self):
35083508
self.assertEqual(info["seldepth"], 8)
35093509
self.assertEqual(info["score"], chess.engine.PovScore(chess.engine.Mate(+3), chess.WHITE))
35103510

3511-
# Info: tbhits, cpuload, hashfull, time, nodes, nps.
3512-
info = chess.engine._parse_uci_info("tbhits 123 cpuload 456 hashfull 789 time 987 nodes 654 nps 321", board)
3511+
# Info: tbhits, cpuload, hashfull, time, nodes, nps, movesleft.
3512+
info = chess.engine._parse_uci_info("tbhits 123 cpuload 456 hashfull 789 movesleft 42 time 987 nodes 654 nps 321", board)
35133513
self.assertEqual(info["tbhits"], 123)
35143514
self.assertEqual(info["cpuload"], 456)
35153515
self.assertEqual(info["hashfull"], 789)
35163516
self.assertEqual(info["time"], 0.987)
35173517
self.assertEqual(info["nodes"], 654)
35183518
self.assertEqual(info["nps"], 321)
3519+
self.assertEqual(info["movesleft"], 42)
35193520

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

0 commit comments

Comments
 (0)