Skip to content

Commit

Permalink
fixes to linux build and path finder crash fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Aki Vänttinen committed Jun 29, 2019
1 parent 7a91330 commit 7fa3bd8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion linux_build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cargo build --release
cp "target/release/libsc2pathlib.so" "sc2pathlib.so"
cp "target/release/libsc2pathlib.so" "sc2pathlibp/sc2pathlib.so"
12 changes: 6 additions & 6 deletions sc2pathlibp/path_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ def map(self) -> List[List[int]]:
"""
return self._path_find.map

def create_block(self, center: Union[Tuple[float, float], List[Tuple[float, float]]], size: Tuple[int, int])
def create_block(self, center: Union[Tuple[float, float], List[Tuple[float, float]]], size: Tuple[int, int]):
if isinstance(center, list):
self._path_find.create_block(center, size)
else:
self._path_find.create_blocks(center, size)
else:
self._path_find.create_block(center, size)

def remove_block(self, center: Union[Tuple[float, float], List[Tuple[float, float]]], size: Tuple[int, int])
def remove_block(self, center: Union[Tuple[float, float], List[Tuple[float, float]]], size: Tuple[int, int]):
if isinstance(center, list):
self._path_find.remove_block(center, size)
else:
self._path_find.remove_blocks(center, size)
else:
self._path_find.remove_block(center, size)

def find_path(self, start: (float, float), end: (float, float)) -> Tuple[List[Tuple[int, int]], float]:
"""
Expand Down
8 changes: 5 additions & 3 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,20 @@ def read_maze(file_name: str) -> List[List[int]]:
print(f"pathfinding took {ns_pf / 1000 / 1000} ms. Total distance {total_distance}")

ns_pf = time.perf_counter_ns()
pf.add_influence([(56, 65), (110, 28), (100, 98)], 150, 50)
pf.add_influence([(56, 65), (110, 28), (100, 98)], 150, 20)
ns_pf = time.perf_counter_ns() - ns_pf
print(f"adding influence took {ns_pf / 1000 / 1000} ms.")

pf.normalize_influence(100)

ns_pf = time.perf_counter_ns()
pf.add_influence_walk([(56, 65), (110, 28), (100, 98)], 150, 50)
pf.add_influence_walk([(56, 65), (110, 28), (100, 98)], 150, 20)
ns_pf = time.perf_counter_ns() - ns_pf
print(f"adding influence by walking distance took {ns_pf / 1000 / 1000} ms.")

result = pf.find_path_influence((29, 65), (154, 114))
print(pf.map)
#print(pf.map)
pf.plot(result[0])
pf.create_block([(11.5,11.5), (21.5,21.5), (31.5,31.5), (31.5,31.5)], (2, 1))
pf.plot(result[0])
input("Press Enter to continue...")

0 comments on commit 7fa3bd8

Please sign in to comment.