Esempio n. 1
0
 def test_getBoard_should_give_array_representation_of_game(self):
     game = Game('X')
     self.assertListEqual(game.getBoard(), ['...'] * 10)
     game.makeMove(1, 'X')
     self.assertListEqual(game.getBoard(), ['...', 'X', '...', '...', '...', '...', '...', '...', '...', '...'])
     game.makeMove(game.getBotMove(), game.getBotSymbol())
     self.assertListEqual(game.getBoard(), ['...', 'X', '...', '...', '...', 'O', '...', '...', '...', '...'])
Esempio n. 2
0
 def test_getBoard_should_give_array_representation_of_game(self):
     game = Game('X')
     self.assertListEqual(game.getBoard(), ['...'] * 10)
     game.makeMove(1, 'X')
     self.assertListEqual(game.getBoard(), [
         '...', 'X', '...', '...', '...', '...', '...', '...', '...', '...'
     ])
     game.makeMove(game.getBotMove(), game.getBotSymbol())
     self.assertListEqual(
         game.getBoard(),
         ['...', 'X', '...', '...', '...', 'O', '...', '...', '...', '...'])
Esempio n. 3
0
 def test_getBotMove_should_try_to_be_winner_if_it_can(self):
     game = Game('X')
     game.makeMove(1, 'O')
     game.makeMove(3, 'O')
     self.assertEquals(game.getBotMove(), 2)
Esempio n. 4
0
 def test_getBotMove_should_block_if_player_can_win_in_next_round(self):
     game = Game('X')
     game.makeMove(1, 'X')
     game.makeMove(3, 'X')
     self.assertEquals(game.getBotMove(), 2)
Esempio n. 5
0
 def test_getBotMove_should_try_to_take_a_corner_if_center_is_not_free(self):
     game = Game('X')
     game.makeMove(5, 'X')
     self.assertTrue(game.getBotMove() in [1, 3, 7, 9])
Esempio n. 6
0
 def test_getBotMove_should_try_to_move_in_middle_if_it_is_free(self):
     game = Game('X')
     self.assertEquals(game.getBotMove(), 5)
Esempio n. 7
0
 def test_getBotMove_should_try_to_be_winner_if_it_can(self):
     game = Game('X')
     game.makeMove(1, 'O')
     game.makeMove(3, 'O')
     self.assertEquals(game.getBotMove(), 2)
Esempio n. 8
0
 def test_getBotMove_should_block_if_player_can_win_in_next_round(self):
     game = Game('X')
     game.makeMove(1, 'X')
     game.makeMove(3, 'X')
     self.assertEquals(game.getBotMove(), 2)
Esempio n. 9
0
 def test_getBotMove_should_try_to_take_a_corner_if_center_is_not_free(
         self):
     game = Game('X')
     game.makeMove(5, 'X')
     self.assertTrue(game.getBotMove() in [1, 3, 7, 9])
Esempio n. 10
0
 def test_getBotMove_should_try_to_move_in_middle_if_it_is_free(self):
     game = Game('X')
     self.assertEquals(game.getBotMove(), 5)