“Redblobgames Pathfinding” Réponses codées

Redblobgames Pathfinding

frontier = Queue()
frontier.put(start )
visited = {}
visited[start] = True

while not frontier.empty():
   current = frontier.get()
   for next in graph.neighbors(current):
      if next not in visited:
         frontier.put(next)
         visited[next] = True
Frail Frog

Redblobgames Pathfinding

current = goal 
path = []
while current != start: 
   path.append(current)
   current = came_from[current]
path.append(start) # optional
path.reverse() # optional
Frail Frog

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code