Releases: DrInfy/sc2-pathlib
Releases · DrInfy/sc2-pathlib
Ladder ready build Linux + Windows v0.4
Various significant performance improvements.
Added find_path_*_closer_than
methods for pathfinding that stops when it's within x distance of the target.
Fixed auto_correct
to actually do something (find closest pathable location).
Recoded find_low_inside
code to use normal pathfinding code.
Ladder ready build Linux + Windows v0.3
Windows and Linux binaries that allow the library to be used in Ladder Manager, ai-arena and sc2ai ladder.
Example initialization of the pathfinder in sc2 4.10.
import sc2pathlibp
from sc2.pixel_map import PixelMap
from sc2.position import Point2
class PathingManager():
def __init__(self, bot):
self.ai = bot
game_info: GameInfo = self.ai.game_info
path_grid = game_info.pathing_grid
_data = [[0 for y in range(path_grid.height)] for x in range(path_grid.width)]
for x in range(0, path_grid.width):
for y in range(0, path_grid.height):
pathable = path_grid.is_set((x, y))
if pathable:
_data[x][y] = 1
self.path_finder = sc2pathlibp.PathFinder(_data)
positions = []
for mf in self.ai.state.mineral_field: # type: Unit
# In 4.8.5+ minerals are no linger visible in pathing grid
positions.append(mf.position)
self.path_finder.create_block(positions, (2, 1))
for enemy_start in self.ai.enemy_start_locations:
self.path_finder.remove_block(enemy_start, (5, 5))
self.path_finder.normalize_influence(100)
def post_update(self):
self.path_finder.plot(self.found_points )
self.found_points.clear()
def find_path(self, start: Point2, target: Point2) -> Point2:
result = self.path_finder.find_path(start, target)
path = result[0]
target_index = 20
if len(path) < 1:
print(f"No path found {start}, {target}")
return target
if len(path) <= target_index:
return target
target = path[target_index]
self.found_points.extend(path) # Debug only
return Point2((target[0] + 0.5, target[1] + 0.5))
Ladder ready Linux+Windows 64-bit build v0.2
Windows and Linux binaries that allow the library to be used in Ladder Manager, ai-arena and Artificial overmind ladder.
Example initialization of the pathfinder in sc2 4.8.4.
import sc2pathlibp
from sc2.pixel_map import PixelMap
from sc2.position import Point2
class PathingManager():
def __init__(self, bot):
self.ai = bot
game_info: GameInfo = self.ai.game_info
path_grid = game_info.pathing_grid
_data = [[0 for y in range(path_grid.height)] for x in range(path_grid.width)]
for x in range(0, path_grid.width):
for y in range(1, path_grid.height):
pathable = not path_grid.is_set((x, y))
if pathable:
_data[x][y - 1] = 1 # This adjustment is needed in 4.8.4 and earlier versions
self.path_finder = sc2pathlibp.PathFinder(_data)
positions = []
for mf in self.ai.state.mineral_field: # type: Unit
# In 4.8.5+ minerals are no linger visible in pathing grid
positions.append(mf.position)
self.path_finder.create_block(positions, (2, 1))
for enemy_start in self.ai.enemy_start_locations:
self.path_finder.remove_block(enemy_start, (5, 5))
self.path_finder.normalize_influence(100)
def post_update(self):
self.path_finder.plot(self.found_points )
self.found_points.clear()
def find_path(self, start: Point2, target: Point2) -> Point2:
result = self.path_finder.find_path(start, target)
path = result[0]
target_index = 20
if len(path) < 1:
print(f"No path found {start}, {target}")
return target
if len(path) <= target_index:
return target
target = path[target_index]
self.found_points.extend(path) # Debug only
return Point2((target[0] + 0.5, target[1] + 0.5))```
Ladder ready first build v0.1.0
Windows and Linux binaries that allow the library to be used in Ladder Manager and ai-arena.