Skip to content

Commit

Permalink
Merge pull request #1054 from AttackingOrDefending/min-time-1ms
Browse files Browse the repository at this point in the history
The python-chess library already does this, but this will make the logs match what the engine sees.
  • Loading branch information
MarkZH authored Dec 11, 2024
2 parents 5b4fbfa + 0c2685a commit af45a16
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/engine_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ def single_move_time(board: chess.Board, game: model.Game, search_time: datetime
"""
pre_move_time = setup_timer.time_since_reset()
overhead = pre_move_time + move_overhead
clock_time = max(msec(0), msec(game.state[wbtime(board)]) - overhead)
clock_time = max(msec(1), msec(game.state[wbtime(board)]) - overhead)
search_time = min(search_time, clock_time)
logger.info(f"Searching for time {sec_str(search_time)} seconds for game {game.id}")
return chess.engine.Limit(time=to_seconds(search_time), clock_id="correspondence")
Expand Down Expand Up @@ -724,7 +724,7 @@ def game_clock_time(board: chess.Board,
overhead = pre_move_time + move_overhead
times = {"wtime": msec(game.state["wtime"]), "btime": msec(game.state["btime"])}
side = wbtime(board)
times[side] = max(msec(0), times[side] - overhead)
times[side] = max(msec(1), times[side] - overhead)
logger.info(f"Searching for wtime {msec_str(times['wtime'])} btime {msec_str(times['btime'])} for game {game.id}")
return chess.engine.Limit(white_clock=to_seconds(times["wtime"]),
black_clock=to_seconds(times["btime"]),
Expand Down

0 comments on commit af45a16

Please sign in to comment.