News for hackers. Stuff that matters.
Re:PathFinding.js by Buttons840 on Wednesday May 27, 2015 @09:07PM (#9615485)
How can you tell if the target is reachable other than finding a path?
Re:PathFinding.js by TheLoneWolfling on Thursday May 28, 2015 @01:21AM (#9616198)
You preprocess the grid into connected components, marking every grid cell with the CC it is in. Then before pathfinding check that the start and end are in the same component. This is an O(1) check, albeit with a potential of O(n log n) space required for storing the array of CC lookups.
Re:PathFinding.js by TheLoneWolfling on Thursday May 28, 2015 @01:31PM (#9619697)
Whoops, make that an O(log n) check, technically speaking, as the index of which CC a cell belongs to may take O(log n) space worst-case.

Though you can treat it as effectively O(1) time and O(n) space.

Re:PathFinding.js by TazeTSchnitzel on Wednesday May 27, 2015 @09:10PM (#9615492)
Check if either the source or destination are completely enclosed.
Re:PathFinding.js by kevan on Wednesday May 27, 2015 @09:37PM (#9615593)
Until the algorithm runs out of nodes to explore it can't know that the destination is unreachable. Checking if a node is enclosed is determining if its graph is disjoint from the graph that the other node is on. The only way to prove the graphs are disjoint is to explore every node in the graph.
Re:PathFinding.js by jankassens on Wednesday May 27, 2015 @10:33PM (#9615772)
In this case it's enough to set the algorithm to "bi-directional". If one side is enclosed it will stop. This only breaks if both disjoint parts are infinite (for example, an infinite wall between start and end.