Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating pathing grid, pathfinding with different sized units, pathing grid fixes #130

Merged
merged 34 commits into from
Jan 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8eda2bd
script to build a ladder compatible binary of the extension
spudde123 Dec 29, 2020
7f5cdc1
add linux build
spudde123 Dec 29, 2020
3d51f1d
updating setup so it works on linux
spudde123 Dec 29, 2020
9d41616
Merge remote-tracking branch 'upstream/develop' into ladder-build
spudde123 Dec 29, 2020
917e823
Fix parameter typo
spudde123 Dec 30, 2020
cb2449e
add test for goldenwall minerals opening
spudde123 Dec 30, 2020
7ccd6e4
Making grid building much faster and more accurate
spudde123 Dec 30, 2020
9bd79de
Fix how a test finds the goldenwall map
spudde123 Dec 30, 2020
ff173a2
Fixing mineral sizes
spudde123 Dec 31, 2020
491c345
Accurate destructable removal first version
spudde123 Dec 31, 2020
f11f81b
Fixing building footprint
spudde123 Dec 31, 2020
0110b96
Save minerals and rocks by position instead of tag
spudde123 Dec 31, 2020
031e84b
Fix comment
spudde123 Dec 31, 2020
27ffa02
Remove print statements from test
spudde123 Jan 1, 2021
ec10494
Adjust test parameters
spudde123 Jan 1, 2021
ec3abaf
Take unit size into account in pathfinding
spudde123 Jan 1, 2021
2336779
Merge branch 'ladder-build' of https://github.com/spudde123/SC2MapAna…
spudde123 Jan 1, 2021
c821232
Remove extra check that was screwing up later code
spudde123 Jan 1, 2021
5870ec1
Changing some checks again
spudde123 Jan 1, 2021
45c46ab
Merge branch 'develop' into ladder-build
spudde123 Jan 1, 2021
fe43685
Fix return types
spudde123 Jan 1, 2021
5a2e5c7
Add function to find eligible points nearby in pather
spudde123 Jan 1, 2021
8031aec
Fix typo
spudde123 Jan 1, 2021
0c2765d
Make sure path start and end points are eligible
spudde123 Jan 1, 2021
8acbed7
Fix air grid generation
spudde123 Jan 1, 2021
39ca942
Fix air vs ground grid
spudde123 Jan 1, 2021
5afffdf
Remove checking path validity, it doesn't go out of bounds
spudde123 Jan 1, 2021
d1081a2
Change test to reflect pathing taking into account unit radius
spudde123 Jan 1, 2021
7495b9b
Add a destructable type
spudde123 Jan 1, 2021
cafbead
Add test for destructable types
spudde123 Jan 1, 2021
a2f4e27
Fix air vs ground test
spudde123 Jan 1, 2021
eed13f9
Update ladder binary
spudde123 Jan 1, 2021
e968780
Add check for whether any sort of pathing is possible
spudde123 Jan 1, 2021
605e2f7
Add docstring to describe find_eligible_point
spudde123 Jan 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MapAnalyzer/Debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ def plot_map(
def plot_influenced_path(self, start: Union[Tuple[float, float], Point2],
goal: Union[Tuple[float, float], Point2],
weight_array: ndarray,
large: bool = False,
smoothing: bool = False,
name: Optional[str] = None,
fontdict: dict = None) -> None:
Expand All @@ -233,6 +234,7 @@ def plot_influenced_path(self, start: Union[Tuple[float, float], Point2],
arr = weight_array.copy()
path = self.map_data.pathfind(start, goal,
grid=arr,
large=large,
smoothing=smoothing,
sensitivity=1)
ax: plt.Axes = plt.subplot(1, 1, 1)
Expand Down
36 changes: 21 additions & 15 deletions MapAnalyzer/MapData.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def pathfind_pyastar(self, start: Union[Tuple[float, float], Point2], goal: Unio
Example:
>>> my_grid = self.get_pyastar_grid()
>>> # start / goal could be any tuple / Point2
>>> path = self.pathfind(start=start,goal=goal,grid=my_grid,allow_diagonal=True, sensitivity=3)
>>> path = self.pathfind_pyastar(start=start,goal=goal,grid=my_grid,allow_diagonal=True, sensitivity=3)

See Also:
* :meth:`.MapData.get_pyastar_grid`
Expand All @@ -325,7 +325,7 @@ def pathfind_pyastar(self, start: Union[Tuple[float, float], Point2], goal: Unio
sensitivity=sensitivity)

def pathfind(self, start: Union[Tuple[float, float], Point2], goal: Union[Tuple[float, float], Point2],
grid: Optional[ndarray] = None, smoothing: bool = False,
grid: Optional[ndarray] = None, large: bool = False, smoothing: bool = False,
sensitivity: int = 1) -> Optional[List[Point2]]:
"""
:rtype: Union[List[:class:`sc2.position.Point2`], None]
Expand All @@ -345,21 +345,25 @@ def pathfind(self, start: Union[Tuple[float, float], Point2], goal: Union[Tuple[

getting every n-``th`` point works better in practice

`` large`` is a boolean that determines whether we are doing pathing with large unit sizes
like Thor and Ultralisk. When it's false the pathfinding is using unit size 1, so if
you want to a guarantee that a unit with size > 1 fits through the path then large should be True.

``smoothing`` tries to do a similar thing on the c side but to the maximum extent possible.
it will skip all the waypoints it can if taking the straight line forward is better
according to the influence grid

Example:
>>> my_grid = self.get_pyastar_grid()
>>> # start / goal could be any tuple / Point2
>>> path = self.pathfind(start=start,goal=goal,grid=my_grid,allow_diagonal=True, sensitivity=3)
>>> path = self.pathfind(start=start,goal=goal,grid=my_grid, large=False, smoothing=False, sensitivity=3)

See Also:
* :meth:`.MapData.get_pyastar_grid`
* :meth:`.MapData.find_lowest_cost_points`

"""
return self.pather.pathfind(start=start, goal=goal, grid=grid, smoothing=smoothing,
return self.pather.pathfind(start=start, goal=goal, grid=grid, large=large, smoothing=smoothing,
sensitivity=sensitivity)

def add_cost(self, position: Tuple[float, float], radius: float, grid: ndarray, weight: float = 100, safe: bool = True,
Expand Down Expand Up @@ -909,24 +913,26 @@ def plot_influenced_path_pyastar(self,
allow_diagonal=allow_diagonal)

def plot_influenced_path(self,
start: Union[Tuple[float, float], Point2],
goal: Union[Tuple[float, float], Point2],
weight_array: ndarray,
smoothing: bool = False,
name: Optional[str] = None,
fontdict: dict = None) -> None:
start: Union[Tuple[float, float], Point2],
goal: Union[Tuple[float, float], Point2],
weight_array: ndarray,
large: bool = False,
smoothing: bool = False,
name: Optional[str] = None,
fontdict: dict = None) -> None:
"""

A useful debug utility method for experimenting with the :mod:`.Pather` module

"""

self.debugger.plot_influenced_path(start=start,
goal=goal,
weight_array=weight_array,
smoothing=smoothing,
name=name,
fontdict=fontdict)
goal=goal,
weight_array=weight_array,
large=large,
smoothing=smoothing,
name=name,
fontdict=fontdict)

def _plot_regions(self, fontdict: Dict[str, Union[str, int]]) -> None:
return self.debugger.plot_regions(fontdict=fontdict)
Expand Down
Loading