Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Calculate only 5s for the first move if the opponent is human
Browse files Browse the repository at this point in the history
Signed-off-by: Đinh Hoàng Việt <[email protected]>
  • Loading branch information
M-DinhHoangViet authored Mar 8, 2024
1 parent a7c274a commit a7cf021
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@


class Engine:
def __init__(self, engine: chess.engine.SimpleEngine, ponder: bool) -> None:
def __init__(self, engine: chess.engine.SimpleEngine, ponder: bool, opponent: chess.engine.Opponent, opponent: chess.engine.Opponent) -> None:
self.engine = engine
self.ponder = ponder
self.opponent = opponent

@classmethod
def from_config(cls, engine_config: dict, syzygy_config: dict, opponent: chess.engine.Opponent) -> 'Engine':
Expand All @@ -19,7 +20,7 @@ def from_config(cls, engine_config: dict, syzygy_config: dict, opponent: chess.e
cls._configure_engine(engine, uci_options)
engine.send_opponent_information(opponent=opponent)

return cls(engine, ponder)
return cls(engine, ponder, opponent)

@staticmethod
def _get_engine_settings(engine_config: dict, syzygy_config: dict) -> tuple[str, bool, int | None, dict]:
Expand Down Expand Up @@ -71,7 +72,7 @@ def make_move(self,
increment: float
) -> tuple[chess.Move, chess.engine.InfoDict]:
if len(board.move_stack) < 2:
limit = chess.engine.Limit(time=15.0)
limit = chess.engine.Limit(time=15.0) if self.opponent.is_engine else chess.engine.Limit(time=5.0)
ponder = False
else:
limit = chess.engine.Limit(white_clock=white_time, white_inc=increment,
Expand Down

0 comments on commit a7cf021

Please sign in to comment.