Пример #1
0
 def testWinner(self):
     test_board = boardutils.winner([' '] * 9)
     self.assertEqual(None, test_board)
     test_board = boardutils.winner(['X', 'X', 'X', ' ', ' ', ' ', ' ', ' ', ' '])
     self.assertEqual('X', test_board)
     test_board = boardutils.winner(['O', 'O', 'O', ' ', ' ', ' ', ' ', ' ', ' '])
     self.assertEqual('O', test_board)
     test_board = boardutils.winner(['X', 'X', 'O', 'O', 'O', 'X', 'X', 'X', 'O'])
     self.assertEqual('Cat', test_board)
Пример #2
0
 def testWinner(self):
     test_board = boardutils.winner([' '] * 9)
     self.assertEqual(None, test_board)
     test_board = boardutils.winner(
         ['X', 'X', 'X', ' ', ' ', ' ', ' ', ' ', ' '])
     self.assertEqual('X', test_board)
     test_board = boardutils.winner(
         ['O', 'O', 'O', ' ', ' ', ' ', ' ', ' ', ' '])
     self.assertEqual('O', test_board)
     test_board = boardutils.winner(
         ['X', 'X', 'O', 'O', 'O', 'X', 'X', 'X', 'O'])
     self.assertEqual('Cat', test_board)
Пример #3
0
def is_legal(x):
    return is_canonical(x) and not boardutils.winner(x)
Пример #4
0
def is_legal(x):
    return is_canonical(x) and not boardutils.winner(x)
Пример #5
0
        self.moves[board] = input_move

    # Resets the board to blank
    def reset_board(self):
        self.moves = {}
        self.board = boardutils.empty_board()

if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    xTally = 0
    oTally = 0
    catTally = 0
    robo = roboplayer.roboplayer()
    for i in range(5001):
        game = SmartTacToe()
        while not boardutils.winner(game.board) and boardutils.winner(game.board) != 'Cat':
            if boardutils.to_move(game.board) == 'X':
                nextMove = robo.x_move(game.board)
                game.board = boardutils.set_move(game.board, nextMove, boardutils.to_move(game.board))
            else:
                nextMove = robo.o_move(game.board)
                game.board = boardutils.set_move(game.board, nextMove, boardutils.to_move(game.board))
            print boardutils.readable_board_string(game.board)
        winnerString = boardutils.winner(game.board)
        robo.adjust(game.board)
        if winnerString == 'X':
            xTally += 1
            break
        elif winnerString == 'O':
            oTally += 1
        else:
Пример #6
0
    # Resets the board to blank
    def reset_board(self):
        self.moves = {}
        self.board = boardutils.empty_board()


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    xTally = 0
    oTally = 0
    catTally = 0
    robo = roboplayer.roboplayer()
    for i in range(5001):
        game = SmartTacToe()
        while not boardutils.winner(
                game.board) and boardutils.winner(game.board) != 'Cat':
            if boardutils.to_move(game.board) == 'X':
                nextMove = robo.x_move(game.board)
                game.board = boardutils.set_move(
                    game.board, nextMove, boardutils.to_move(game.board))
            else:
                nextMove = robo.o_move(game.board)
                game.board = boardutils.set_move(
                    game.board, nextMove, boardutils.to_move(game.board))
            print boardutils.readable_board_string(game.board)
        winnerString = boardutils.winner(game.board)
        robo.adjust(game.board)
        if winnerString == 'X':
            xTally += 1
            break
        elif winnerString == 'O':