Skip to content

Commit

Permalink
test: now testing clean_air_grid for dtype bugfix by checking path le…
Browse files Browse the repository at this point in the history
…ngths
  • Loading branch information
eladyaniv01 committed Oct 1, 2020
1 parent 278241c commit b47bae4
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/test_pathihng.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from _pytest.logging import LogCaptureFixture
from _pytest.python import Metafunc
from sc2.position import Point2

from MapAnalyzer import Region
from MapAnalyzer.MapData import MapData
Expand Down Expand Up @@ -158,6 +159,39 @@ def test_find_lowest_cost_points(self, map_data: MapData) -> None:
p] == cost), f"grid type = climber_grid, p = {p}, influence_grid[p] = {influence_grid[p]}, expected cost = {cost}"
assert (map_data.distance(cost_point, p) < expected_max_distance)

def test_clean_air_grid_allow_diagonal_true(self, map_data: MapData) -> None:
default_weight = 2
base = map_data.bot.townhalls[0]
reg_start = map_data.where_all(base.position_tuple)[0]
reg_end = map_data.where_all(map_data.bot.enemy_start_locations[0].position)[0]
p0 = Point2(reg_start.center)
p1 = Point2(reg_end.center)
grid = map_data.get_clean_air_grid(default_weight=default_weight)
cost_points = [(87, 76), (108, 64), (97, 53)]
cost_points = list(map(Point2, cost_points))
for cost_point in cost_points:
grid = map_data.add_cost(position=cost_point, radius=7, grid=grid)
path = map_data.pathfind(start=p0, goal=p1, grid=grid, allow_diagonal=True)
assert (len(path) < 200)

def test_clean_air_grid_allow_diagonal_false(self, map_data: MapData) -> None:
"""
non diagonal path should be longer, but still below 250
"""
default_weight = 2
base = map_data.bot.townhalls[0]
reg_start = map_data.where_all(base.position_tuple)[0]
reg_end = map_data.where_all(map_data.bot.enemy_start_locations[0].position)[0]
p0 = Point2(reg_start.center)
p1 = Point2(reg_end.center)
grid = map_data.get_clean_air_grid(default_weight=default_weight)
cost_points = [(87, 76), (108, 64), (97, 53)]
cost_points = list(map(Point2, cost_points))
for cost_point in cost_points:
grid = map_data.add_cost(position=cost_point, radius=7, grid=grid)
path = map_data.pathfind(start=p0, goal=p1, grid=grid, allow_diagonal=False)
assert (len(path) < 250)

def test_air_vs_ground(self, map_data: MapData) -> None:
default_weight = 99
grid = map_data.get_air_vs_ground_grid(default_weight=default_weight)
Expand Down

0 comments on commit b47bae4

Please sign in to comment.