Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

An equivalent formulation to the SO solution with a simple implementation is to double the vertices and edges in the graph G by making a duplicate parallel universe G'. One can always move from v in G to its corresponding v' in G' at zero cost, but there is also a cost-1 edge from vertex u in G to v' in G' whenever u and v are separated by a wall. Once one crosses into G', there is no going back.

One can pass the new graph, G ∪ G' plus all the intermediate edges, into the already existing A* implementation to search for an optimal s-t' path. This works as long as the heuristic for v is also admissible for v', but most are. I think all three of these algorithms could in principle run into problems for certain uncommon admissible heuristics.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: