def test_for_winner_true(self): board = [ [0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, -1], [0, 0, 0, 0], ] assert check_for_player_win(transform_board_for_game(board), 1, 2, PlayerToken.X)
def test_for_winner_in_diagonal(self): board = [ [0, 0, 0, 0, 0], [0, 0, 1, 1, 0], [1, 1, -1, -1, -1], [1, -1, -1, -1, 1], ] assert check_for_player_win(transform_board_for_game(board), 0, 3, PlayerToken.X)
def test_for_winner_false(self): board = [ [0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, -1], [0, 0, 0, 0], ] self.assertFalse( check_for_player_win(transform_board_for_game(board), 1, 2, PlayerToken.O))
def test_get_valid_moves_for_even_board(self): expected_moves = [(2, 1), (2, 2), (2, 0), (2, 3)] board = [ [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [1, -1, -1, 1], ] self.assertEqual(expected_moves, get_valid_moves(transform_board_for_game(board)))
def test_if_ai_could_block_move_3(self): board = [ [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, -1, 0, 0, -1], [1, 1, 1, 0, -1], ] expected_move = 3 self.assertEqual( expected_move, get_move_with_alpha_beta(transform_board_for_game(board), 4, PlayerToken.O))
def test_count_in_vertical(self): expected_counter = 3 player = PlayerToken.X move = (1, 0) board = [ [0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 0, 0], [1, -1, -1, 1], ] self.assertEqual( expected_counter, count_in_vertical(transform_board_for_game(board), player, move))
def test_count_in_horizontal_2(self): expected_counter = 0 player = PlayerToken.X move = (3, 2) board = [ [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [1, 1, 0, -1], ] self.assertEqual( expected_counter, count_in_horizontal(transform_board_for_game(board), player, move))
def test_count_in_diagonal_4(self): expected_counter = 0 player = PlayerToken.O move = (1, 1) board = [ [1, 0, 0, 0], [-1, 0, 0, 0], [1, 1, -1, 0], [1, 1, -1, -1], ] self.assertEqual( expected_counter, count_from_up_left_to_down_right(transform_board_for_game(board), player, move))