From ba8459797c667cfa7fb016f72d6f6d0597657e6d Mon Sep 17 00:00:00 2001 From: Cameron Smart Date: Mon, 20 Apr 2020 02:34:19 -0700 Subject: [PATCH] Removed tabs and training white space. --- triple-dungeon/path.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/triple-dungeon/path.py b/triple-dungeon/path.py index 46a7eea..6a062fd 100644 --- a/triple-dungeon/path.py +++ b/triple-dungeon/path.py @@ -2,20 +2,23 @@ from pathfinding.core.diagonal_movement import DiagonalMovement from pathfinding.core.grid import Grid from pathfinding.finder.a_star import AStarFinder + def route(start, end, matrix) -> path: - """ - Take a matrix of the level in the form wighted numbers, a start and stop point, and return a path between them. + """ + Take a matrix of the level in the form wighted numbers, a start and stop point, and return a path between them. + + param: start: (x, y) location of the monster + param: end: (x, y) location of the player + param: matrix: a 2d list of the level. 0s are walls, numbers greater than 0 are weighted + """ + + grid = Grid(matrix=matrix) + start = grid.node(start[0], start[1]) + end = grid.node(end[0], end[1]) + finder = AStarFinder(diagonal_movement=DiagonalMovement.always) + path, runs = finder.find_path(start, end, grid) + + return path - param: start: (x, y) location of the monster - param: end: (x, y) location of the player - param: matrix: a 2d list of the level. 0s are walls, numbers greater than 0 are weighted - """ - grid = Grid(matrix=matrix) - start = grid.node(start[0],start[1]) - end = grid.node(end[0], end[1]) - finder = AStarFinder(diagonal_movement=DiagonalMovement.always) - path, runs = finder.find_path(start, end, grid) - #grid.grid_str(path=path, start=start, end=end) - return path