diff --git a/plugin/chess/__init__.py b/plugin/chess/__init__.py index 75adc79..73a485e 100644 --- a/plugin/chess/__init__.py +++ b/plugin/chess/__init__.py @@ -34,7 +34,7 @@ def execute(cinput: ControlInput, graphics: Graphics, _): sunfish.initial, 0, (True,True), (True,True), 0, 0)] player_color = 'wb'[get_color(hist[-1])] - draw.draw_board(hist[-1] if player_color == "w" else hist[-1].rotate(), player_color) + draw.draw_board(hist[-1], player_color) state = GameState.MAIN_MENU menu_index = 0 @@ -58,14 +58,10 @@ def execute(cinput: ControlInput, graphics: Graphics, _): if time.time() - start > MAX_THINKING_SECONDS: break hist.append(hist[-1].move(move)) - draw.draw_board(hist[-1].rotate(), player_color) + draw.draw_board(hist[-1], player_color) last_move = move_str(move, player_color == "w") - if score == sunfish.MATE_UPPER: - draw.draw_checkmate(last_move, False) - state = GameState.GAME_OVER - else: - all_moves = dict() - state = GameState.CHOOSE_SRC + all_moves = dict() + state = GameState.CHOOSE_SRC elif state == GameState.CHOOSE_SRC: if len(list(all_moves)) == 0: all_moves = get_all_moves(hist[-1]) @@ -105,7 +101,7 @@ def execute(cinput: ControlInput, graphics: Graphics, _): player_color = "w" state = GameState.CHOOSE_SRC hist = [pos] - draw.draw_board(hist[-1], player_color) + draw.draw_board(hist[-1] if player_color == "w" else hist[-1].rotate(), player_color) elif state == GameState.CHOOSE_SRC: if key == Button.DIR_D or key == Button.DIR_R: src_idx += 1 @@ -138,7 +134,7 @@ def execute(cinput: ControlInput, graphics: Graphics, _): draw.draw_board(hist[-1].rotate(), player_color) state = GameState.THINKING else: - if key == Button.BTN_A: + if key == Button.BTN_A or key == Button.BTN_B: state = GameState.MAIN_MENU def get_all_moves(pos: sunfish.Position): diff --git a/plugin/chess/draw.py b/plugin/chess/draw.py index 0f2dd3e..47e4076 100644 --- a/plugin/chess/draw.py +++ b/plugin/chess/draw.py @@ -81,8 +81,7 @@ class Draw: def draw_board(self, pos: Position, player_color: str): self._graphics.fill_rect(0, 0, self.BOARD_SIZE, self.BOARD_SIZE, 0) - nb = "".join(pos.board.split()) - nb = nb[::-1] if player_color == "b" else nb + nb = "".join(pos.board.split()) if player_color == "w" else "".join(pos.rotate().board.split())[::-1] c = True for row in range(8): for col in range(8): diff --git a/plugin/chess/sunfish.py b/plugin/chess/sunfish.py index 68ebd59..d786862 100644 --- a/plugin/chess/sunfish.py +++ b/plugin/chess/sunfish.py @@ -295,7 +295,7 @@ class Searcher: # Note, we don't have to check for legality, since we've already done it # before. Also note that in QS the killer must be a capture, otherwise we # will be non deterministic. - killer = selfctp_move.get(pos) + killer = self.tp_move.get(pos) if killer and (depth > 0 or pos.value(killer) >= QS_LIMIT): yield killer, -self.bound(pos.move(killer), 1-gamma, depth-1, root=False) # Then all the other moves