Skip to content

Commit

Permalink
Remove some asserts in game.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Torom committed Nov 22, 2023
1 parent 52acf15 commit 8ce190a
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions game.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def __init__(self, config: dict, api: API, game_id: str, game_finished_event: Ev
self.api = api
self.game_id = game_id
self.game_finished_event = game_finished_event
self.lichess_game: Lichess_Game | None = None
self.chatter: Chatter | None = None
self.game_info: Game_Information | None = None
self.lichess_game: Lichess_Game
self.chatter: Chatter
self.game_info: Game_Information

def start(self):
Thread.start(self)
Expand Down Expand Up @@ -91,9 +91,6 @@ def run(self) -> None:
self.game_finished_event.set()

def _make_move(self) -> None:
assert self.lichess_game
assert self.chatter

uci_move, offer_draw, resign = self.lichess_game.make_move()
if resign:
self.api.resign_game(self.game_id)
Expand All @@ -102,9 +99,6 @@ def _make_move(self) -> None:
self.chatter.print_eval()

def _finish_game(self, winner: str | None) -> bool:
assert self.lichess_game
assert self.chatter

if self.lichess_game.is_finished:
self._print_result_message(winner)
self.chatter.send_goodbyes()
Expand All @@ -113,8 +107,6 @@ def _finish_game(self, winner: str | None) -> bool:
return False

def _print_game_information(self) -> None:
assert self.game_info

opponents_str = f'{self.game_info.white_str} - {self.game_info.black_str}'
delimiter = 5 * ' '

Expand All @@ -124,9 +116,6 @@ def _print_game_information(self) -> None:
print(128 * '‾')

def _print_result_message(self, winner: str | None) -> None:
assert self.lichess_game
assert self.game_info

if winner:
if winner == 'white':
message = f'{self.game_info.white_name_str} won'
Expand Down

0 comments on commit 8ce190a

Please sign in to comment.