Skip to content

Commit

Permalink
test old make moves but with 203 nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoknjas committed Aug 29, 2024
1 parent 0b40c48 commit ebb72a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion stockfish/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ def make_moves_from_current_position(self, moves: Optional[List[str]]) -> None:
if not moves:
return
self._prepare_for_new_position(False)
self._put(f"position fen {self.get_fen_position()} moves {' '.join(moves)}")
for move in moves:
self._put(f"position fen {self.get_fen_position()} moves {move}")

def get_board_visual(self, perspective_white: bool = True) -> str:
"""Returns a visual representation of the current board position.
Expand Down Expand Up @@ -931,6 +932,14 @@ def get_top_moves(
if ("multipv" not in line) or ("depth" not in line):
break

# if we're searching depth and the line is not our desired depth, we're done
if (
(num_nodes == 0)
and (wtime is None and btime is None)
and (int(self._pick(line, "depth")) != self._depth)
):
break

# if we're searching nodes and the line has less than desired number of nodes, we're done
if (num_nodes > 0) and (int(self._pick(line, "nodes")) < self._num_nodes):
break
Expand Down
2 changes: 1 addition & 1 deletion tests/stockfish/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_get_best_move_remaining_time_not_first_move(self, stockfish: Stockfish)
stockfish.make_moves_from_current_position(["e2e4", "e7e6"])
best_move = stockfish.get_best_move(wtime=1000)
assert best_move in ("d2d4", "a2a3", "d1e2", "b1c3")
assert stockfish.get_top_moves(btime=1000)[0]["Move"] in ("d2d4", "b1c3")
assert stockfish.get_top_moves(num_nodes=203)[0]["Move"] in ("d2d4", "b1c3")
best_move = stockfish.get_best_move(wtime=1000, btime=1000)
assert best_move in ("d2d4", "b1c3", "g1f3")
best_move = stockfish.get_best_move(wtime=5 * 60 * 1000, btime=1000)
Expand Down

0 comments on commit ebb72a3

Please sign in to comment.