示例#1
0
    def test(self):
        board = TicTacToeBoard(3, False, None)
        original_state = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

        self.assertEqual(board.board, original_state)

        mc_trial(board, PLAYERX)
        
        self.assertNotEqual(board.board, original_state)
        self.assertNotEqual(board.evaluate_win_status(), None)
示例#2
0
"""
Runs the monte carlo simulation for specified number of times
"""

from monte_carlo_tictactoe import mc_move
from tictactoe_board import (PLAYERX, switch_player, TicTacToeBoard)

BOARD = TicTacToeBoard(3, False, None)
NUM_TRIALS = 500

PLAYER = PLAYERX
win = None

while not win:
    MOVE = mc_move(BOARD, PLAYER, NUM_TRIALS)
    BOARD.move(MOVE[0], MOVE[1], PLAYER)
    PLAYER = switch_player(PLAYER)
    print BOARD.__str__() + '\n'
    win = BOARD.evaluate_win_status()

print "win: " + str(win)
示例#3
0
    def test_winning_bleft_diagonal(self):
        tictactoe_board = TicTacToeBoard(3, False, None)
        tictactoe_board.board = [[0, 0, 2], [0, 2, 0], [2, 1, 1]]

        self.assertEqual(tictactoe_board.evaluate_win_status(), PLAYERO)
示例#4
0
    def test_tie(self):
        tictactoe_board = TicTacToeBoard(3, False, None)
        tictactoe_board.board = [[1, 1, 2], [2, 2, 1], [1, 2, 1]]

        self.assertEqual(tictactoe_board.evaluate_win_status(), DRAW)
示例#5
0
    def test_empty_board(self):
        tictactoe_board = TicTacToeBoard(3, False, None)
        tictactoe_board.board = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

        self.assertEqual(tictactoe_board.evaluate_win_status(), None)