示例#1
0
    def test_draw_boards(self):
        boards = [{
            'board': [['X', 'O', 'X'], ['X', 'O', 'X'], ['O', 'X', 'O']],
            'winner': None
        }, {
            'board': [['O', 'X', 'O'], ['O', 'X', 'X'], ['X', 'O', 'X']],
            'winner': None
        }]

        for item in boards:
            self.assertEqual(ttt.winner(item['board']), item['winner'])
示例#2
0
    def test_diagonal_boards(self):
        boards = [{
            'board': [['O', '·', 'X'], ['·', 'X', '·'], ['X', '·', 'O']],
            'winner': 'X'
        }, {
            'board': [['O', 'X', 'X'], ['·', 'O', '·'], ['X', 'O', 'O']],
            'winner': 'O'
        }]

        for item in boards:
            self.assertEqual(ttt.winner(item['board']), item['winner'])
示例#3
0
 def test_X_won_vertical_begin(self):
     moves = 'xo_' \
             'xo_' \
             'x__'
     self.assertEqual(winner(moves), X)
示例#4
0
 def test_O_won_diagonal_right_to_left(self):
     moves = 'x_o' \
             'xo_' \
             'o__'
     self.assertEqual(winner(moves), O)
示例#5
0
 def test_O_won_diagonal_left_to_right(self):
     moves = 'ox_' \
             'xo_' \
             '__o'
     self.assertEqual(winner(moves), O)
示例#6
0
 def test_X_won_diagonal_right_to_left(self):
     moves = 'o_x' \
             'ox_' \
             'x__'
     self.assertEqual(winner(moves), X)
示例#7
0
 def test_X_won_diagonal_left_to_right(self):
     moves = 'xo_' \
             'ox_' \
             '__x'
     self.assertEqual(winner(moves), X)
示例#8
0
 def test_O_won_vertical_begin(self):
     moves = 'ox_' \
             'ox_' \
             'o__'
     self.assertEqual(winner(moves), O)
示例#9
0
 def test_O_won_horizontal_begin(self):
     moves = 'ooo' \
             'x_x' \
             '___'
     self.assertEquals(winner(moves), O)
示例#10
0
 def test_X_won_horizontal_end(self):
     moves = '___' \
             'o_o' \
             'xxx'
     self.assertEquals(winner(moves), X)
示例#11
0
 def test_X_won_horizontal_middle(self):
     moves = '_o_' \
             'xxx' \
             'o_o'
     self.assertEquals(winner(moves), X)
示例#12
0
 def test_tie_2(self):
     moves = 'xox' \
             'oxo' \
             'oxo'
     self.assertEqual(winner(moves), TIE)
示例#13
0
 def test_X_won_horizontal_begin(self):
     moves = 'xxx' \
             'o_o' \
             '___'
     self.assertEquals(winner(moves), X)
示例#14
0
 def test_O_won_vertical_end(self):
     moves = '__o' \
             'x_o' \
             'x_o'
     self.assertEqual(winner(moves), O)
示例#15
0
 def test_X_won_vertical_middle(self):
     moves = '_xo' \
             '_xo' \
             '_x_'
     self.assertEqual(winner(moves), X)
示例#16
0
 def test_O_won_horizontal_middle(self):
     moves = '_x_' \
             'ooo' \
             'x_x'
     self.assertEquals(winner(moves), O)
示例#17
0
 def test_X_won_vertical_end(self):
     moves = '__x' \
             'o_x' \
             'o_x'
     self.assertEqual(winner(moves), X)
示例#18
0
 def test_O_won_horizontal_end(self):
     moves = '___' \
             'x_x' \
             'ooo'
     self.assertEquals(winner(moves), O)
示例#19
0
 def test_O_won_vertical_middle(self):
     moves = '_ox' \
             '_ox' \
             '_o_'
     self.assertEqual(winner(moves), O)
示例#20
0
文件: testTTT.py 项目: mgautamk/AI
    def test_winning_board_state(self):
        self.game.grid = 'xxx      '
        self.assertEqual(winner(self.game.grid), 'x')

        self.game.grid = 'xoxoxoxox'
        self.assertEqual(winner(self.game.grid), 'x')