Esempio n. 1
0
 def _ai_make_move(self, dt):
     '''Have the AI make its next move'''
     if not self.two_player:
         ai_move = AI.get_next_move(
             self.board, Players.other_player(self.human_player))
         if ai_move:
             ai_move_row, ai_move_columnn = ai_move
             self._make_move(ai_move_row, ai_move_columnn)
Esempio n. 2
0
 def _undo_move(self):
     '''Internal method to undo the previous move'''
     # Remove move from internal board
     move = self.board.undo_move()
     # If there was a move to undo
     if move:
         row, column = move
         # Remove player's icon from tile
         self.grid.set_tile_icon(
             row, column, self.player_icons[Players.unplayed])
         # Return to previous turn
         self.player = Players.other_player(self.player)
         self.previous.title = self.player_names[self.player]
Esempio n. 3
0
    def _handle_move_results(self, win_status):
        '''Handle the results of a move

        Based on the results of a move, end a game and display win/tie message or
         just advance to the next turn
        '''
        gameover, winner = win_status
        if gameover:
            self.game_over = True
            # Cat's game
            if winner == Results.tie:
                self.message.display_message("Cat's game!")
            else:
                self.grid.display_win(self.board.get_winning_streak())
                Clock.schedule_once(self._display_win_message, 0.3)
            return False
        # If no win, advance to next turn
        self.player = Players.other_player(self.player)
        self.previous.title = self.player_names[self.player]
        return True