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', '...', '...', '...', '...'])
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', '...', '...', '...', '...'])
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)
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)
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])
def test_getBotMove_should_try_to_move_in_middle_if_it_is_free(self): game = Game('X') self.assertEquals(game.getBotMove(), 5)
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])