Пример #1
0
 def testToMove(self):
     next_move = boardutils.to_move([' '] * 9)
     self.assertEqual('X', next_move)
     next_move = boardutils.to_move(
         ['X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '])
     self.assertEqual('O', next_move)
Пример #2
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':
            oTally += 1
        else:
            catTally += 1
Пример #3
0
 def testToMove(self):
     next_move = boardutils.to_move([' '] * 9)
     self.assertEqual('X', next_move)
     next_move = boardutils.to_move(['X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '])
     self.assertEqual('O', next_move)
Пример #4
0
    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