I'm currently attempting to utilize A* pathfinding in my 2D-sidescroller-procedurally generated world game (think Terraria-like terrain).
I've been using this resource: http://www.redblobgames.com/pathfinding/a-star/introduction.html
And have been mainly using the following pseudocode given:
frontier = PriorityQueue()
frontier.put(start, 0)
came_from = {}
cost_so_far = {}
came_from[start] = None
cost_so_far[start] = 0
while not frontier.empty():
current = frontier.get()
if current == goal:
break
for next in graph.neighbors(current):
new_cost = cost_so_far[current] + graph.cost(current, next)
if next not in cost_so_far or new_cost < cost_so_far[next]:
cost_so_far[next] = new_cost
priority = new_cost + heuristic(goal, next)
frontier.put(next, priority)
came_from[next] = current
My question is: in a 2D-sidescroller with a large procedurally-generated world, how do I choose the frontier? The path to a specific tile could be any distance away, and it obviously seems unwise to iterate over the entire map.
I'm trying to do this efficiently, so any assistance would be appreciated!