현재 2D- sidescroller- 절차 적으로 생성 된 세계 게임 (Terraria와 유사한 지형)에서 A * 길 찾기를 활용하려고합니다.A * 2D Sidescroller의 길 찾기
나는이 자원을 사용하고 : http://www.redblobgames.com/pathfinding/a-star/introduction.html
을 주로 주어진 다음 의사 사용하고 있습니다 :
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
내 질문은 : 많은 절차 적으로 생성 된 세계와 차원 - 횡 스크롤의를 , 내가 어떻게 국경을 선택합니까? 특정 타일에 대한 경로는 멀리 떨어져있을 수 있으며 전체지도를 반복하는 것이 현명하지 못한 것처럼 보입니다.
나는 이것을 효율적으로하기 위해 노력하고 있으므로 어떤 도움을 주시면 감사하겠습니다!
공개 노드에 넣을 노드를 어떻게 알 수 있습니까? 그것은 단순히 이웃들입니까? 따라서 2D sidescroller의 경우 기본적으로 위, 아래, 왼쪽 및 오른쪽 노드가됩니까? – Jestus