def setUpSearch(cls): search = Expando() search.maze = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]] search.totalNodes = 16 search.startPosition = (0, 0) search.endPosition = (1, 3) search.astar = AStar(heuristicFunction) search.pathMap = search.astar.findPath(search.maze, search.startPosition, search.endPosition) search.path = search.astar.pathToNode(search.pathMap, search.endPosition) cls.search = search
def setUpSearch(cls): search = Expando() search.maze = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 0, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1]] search.totalNodes = 20 search.startPosition = (0, 0) search.endPosition = (4, 4) search.astar = AStar() search.pathMap = search.astar.findPath(search.maze, search.startPosition, search.endPosition) search.path = search.astar.pathToNode(search.pathMap, search.endPosition) cls.search = search
from astar.AStar import AStar from astar.HeuristicFunctions import manhattan as heuristicFunction from my_logger import astar_logger as logger # import logging # logger.setLevel(logging.DEBUG) maze = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [6, 1, 1, 1, 1]] startPosition = (0, 2) endPosition = (4, 4) # Dijkstra dijkstra = AStar() searchMap = dijkstra.findPath(maze, startPosition, endPosition) shortestPath = dijkstra.pathToNode(searchMap, endPosition) # logger.info(f"{searchMap}") logger.info(f"{shortestPath}") # Astar astar = AStar(heuristicFunction) searchMap = astar.findPath(maze, startPosition, endPosition) shortestPath = astar.pathToNode(searchMap, endPosition) # logger.info(f"{searchMap}") logger.info(f"{shortestPath}")