Пример #1
0
def test_minerals_walls() -> None:
    # attempting to path through mineral walls in goldenwall should fail
    path = os.path.join(get_map_files_folder(), 'GoldenWallLE.xz')
    # logger.info(path)
    map_data = mock_map_data(path)
    start = (110, 95)
    goal = (110, 40)
    grid = map_data.get_pyastar_grid()
    path = map_data.pathfind(start=start, goal=goal, grid=grid)
    assert (path is None)
    # also test climber grid for nonpathables
    grid = map_data.get_climber_grid()
    path = map_data.pathfind(start=start, goal=goal, grid=grid)
    assert (path is None)

    # remove the mineral wall that is blocking pathing from the left player's base to the bottom
    # side of the map
    map_data.bot.destructables = map_data.bot.destructables.filter(
        lambda x: x.distance_to((46, 41)) > 5)
    grid = map_data.get_pyastar_grid()
    path = map_data.pathfind(start=start, goal=goal, grid=grid)
    assert (path is not None)

    # attempting to path through tight pathways near destructables should work
    path = os.path.join(get_map_files_folder(), 'AbyssalReefLE.xz')
    map_data = mock_map_data(path)
    start = (130, 25)
    goal = (125, 47)
    grid = map_data.get_pyastar_grid()
    path = map_data.pathfind(start=start, goal=goal, grid=grid)
    assert (path is not None)
def test_minerals_walls() -> None:
    # attempting to path through mineral walls in goldenwall should fail
    import pathlib
    li = sorted(pathlib.Path('..').glob('**/*GoldenWallLE.xz'))
    # path = os.path.join(get_map_files_folder(), 'GoldenWallLE.xz')
    path = li[0].absolute()
    # logger.info(path)
    map_data = mock_map_data(path)
    start = (110, 95)
    goal = (110, 40)
    grid = map_data.get_pyastar_grid()
    path = map_data.pathfind(start=start, goal=goal, grid=grid)
    assert (path is None)
    # also test climber grid for nonpathables
    grid = map_data.get_climber_grid()
    path = map_data.pathfind(start=start, goal=goal, grid=grid)
    assert (path is None)

    # attempting to path through tight pathways near destructables should work
    path = os.path.join(get_map_files_folder(), 'AbyssalReefLE.xz')
    map_data = mock_map_data(path)
    start = (130, 25)
    goal = (125, 47)
    grid = map_data.get_pyastar_grid()
    path = map_data.pathfind(start=start, goal=goal, grid=grid)
    assert (path is not None)
Пример #3
0
def test_mapdata(n, m):
    map_files = get_map_file_list()
    map_data = mock_map_data(random.choice(map_files))
    # map_data.plot_map()
    logger.info(
        f"Loaded Map : {map_data.bot.game_info.map_name}, n,m = {n}, {m}")
    # tuples
    points = [(i, j) for i in range(n + 1) for j in range(m + 1)]
    set_points = set(points)
    indices = map_data.points_to_indices(set_points)
    i = randint(0, n)
    j = randint(0, m)
    assert (i, j) in points
    assert (i, j) in set_points
    assert i in indices[0] and j in indices[1]
    new_points = map_data.indices_to_points(indices)
    assert new_points == set_points

    # Point2's
    points = [Point2((i, j)) for i in range(n + 1) for j in range(m + 1)]

    for point in points:
        assert (point is not None)
    set_points = set(points)
    indices = map_data.points_to_indices(set_points)
    i = randint(0, n)
    j = randint(0, m)
    assert (i, j) in points
    assert (i, j) in set_points
    assert i in indices[0] and j in indices[1]
    new_points = map_data.indices_to_points(indices)
    assert new_points == set_points
Пример #4
0
def test_destructable_types() -> None:
    map_list = get_map_file_list()
    dest_types = set()
    for map in map_list:
        map_data = mock_map_data(map)
        for dest in map_data.bot.destructables:
            dest_types.add((dest.type_id, dest.name))

    rock_types = set()
    rock_types.update(destructable_ULBR)
    rock_types.update(destructable_BLUR)
    rock_types.update(destructable_6x2)
    rock_types.update(destructable_4x4)
    rock_types.update(destructable_2x4)
    rock_types.update(destructable_2x2)
    rock_types.update(destructable_2x6)
    rock_types.update(destructable_4x2)
    rock_types.update(destructable_4x12)
    rock_types.update(destructable_6x6)
    rock_types.update(destructable_12x4)

    for dest in dest_types:
        handled = False
        type_id = dest[0]
        name = dest[1].lower()
        if 'mineralfield450' in name:
            handled = True
        elif 'unbuildable' in name:
            handled = True
        elif 'acceleration' in name:
            handled = True
        elif type_id in rock_types:
            handled = True

        assert handled, f"Destructable {type_id} with name {name} is not handled"
Пример #5
0
def get_map_datas() -> Iterable[MapData]:
    subfolder = "MapAnalyzer"
    subfolder2 = "pickle_gameinfo"
    subfolder = os.path.join(subfolder, subfolder2)
    if "tests" in os.path.abspath("."):
        folder = os.path.dirname(os.path.abspath("."))
    else:
        folder = os.path.abspath(".")
    map_files_folder = os.path.join(folder, subfolder)
    map_files = os.listdir(map_files_folder)
    for map_file in map_files:
        yield mock_map_data(map_file=os.path.join(map_files_folder, map_file))
Пример #6
0
def test_climber_grid() -> None:
    """assert that we can path through climb cells with climber grid,
    but not with normal grid"""
    path = os.path.join(get_map_files_folder(), 'GoldenWallLE.xz')

    map_data = mock_map_data(path)
    start = (150, 95)
    goal = (110, 40)
    grid = map_data.get_pyastar_grid()
    path = map_data.pathfind(start=start, goal=goal, grid=grid)
    assert (path is None)
    grid = map_data.get_climber_grid()
    path = map_data.pathfind(start=start, goal=goal, grid=grid)
    assert (path is None)
def test_climber_grid() -> None:
    """assert that we can path through climb cells with climber grid,
    but not with normal grid"""
    import pathlib
    li = sorted(pathlib.Path('..').glob('**/*GoldenWallLE.xz'))
    path = li[0].absolute()
    map_data = mock_map_data(path)
    start = (150, 95)
    goal = (110, 40)
    grid = map_data.get_pyastar_grid()
    path = map_data.pathfind(start=start, goal=goal, grid=grid)
    assert (path is None)
    grid = map_data.get_climber_grid()
    path = map_data.pathfind(start=start, goal=goal, grid=grid)
    assert (path is None)