def test_3by3_single_player_no_pushback_rule(library_path): """ Performs two library calls: the first without previous shift, the second with a previous shift invalidating the shift result of the first call. """ test_setup = (MAZE_3BY3, "NS", [(0, 0)], (0, 2)) previous_shift_location = None board, piece = _create_board(test_setup) library_binding = ExternalLibraryBinding( library_path, board, piece, previous_shift_location=previous_shift_location) action_1 = library_binding.find_optimal_action() _assert_valid_action(action_1, board, previous_shift_location, piece) shift_location_1 = action_1[0][0] board, piece = _create_board(test_setup) previous_shift_location = board.opposing_border_location(shift_location_1) library_binding = ExternalLibraryBinding( library_path, board, piece, previous_shift_location=previous_shift_location) action_2 = library_binding.find_optimal_action() _assert_valid_action(action_2, board, previous_shift_location, piece) shift_location_2 = action_2[0][0] assert shift_location_2 != shift_location_1
def test_3by3_single_player_with_objective_on_leftover(library_path): test_setup = (MAZE_3BY3, "NE", [(0, 0)], "leftover") previous_shift_location = BoardLocation(1, 2) board, piece = _create_board(test_setup) library_binding = ExternalLibraryBinding( library_path, board, piece, previous_shift_location=previous_shift_location) action = library_binding.find_optimal_action() _assert_valid_action(action, board, previous_shift_location, piece)
def test_3by3_single_player_no_direct_path_without_previous_shift( library_path): test_setup = (MAZE_3BY3, "NE", [(0, 0)], (2, 2)) previous_shift_location = None board, piece = _create_board(test_setup) library_binding = ExternalLibraryBinding( library_path, board, piece, previous_shift_location=previous_shift_location) action = library_binding.find_optimal_action() _assert_valid_action(action, board, previous_shift_location, piece)
def test_second_player_to_play__performs_valid_action(library_path): test_setup = (MAZE_3BY3, "NS", [(0, 0), (2, 2)], (2, 1)) previous_shift_location = None board, _ = _create_board(test_setup) piece = board.pieces[1] library_binding = ExternalLibraryBinding( library_path, board, piece, previous_shift_location=previous_shift_location) action = library_binding.find_optimal_action() _assert_valid_action(action, board, previous_shift_location, piece) _assert_reaches_objective(action, board, piece)
def test_3by3_single_player_no_fresh_board(library_path): """ Creates a board and makes two shifts, so that the maze card ids are no longer regularly distributed row-first """ test_setup = (MAZE_3BY3, "NS", [(0, 0)], (0, 2)) previous_shift_location = BoardLocation(1, 2) board, piece = _create_board(test_setup) board.shift(BoardLocation(1, 2), 0) board.shift(BoardLocation(2, 1), 0) library_binding = ExternalLibraryBinding( library_path, board, piece, previous_shift_location=previous_shift_location) action = library_binding.find_optimal_action() _assert_valid_action(action, board, previous_shift_location, piece)