r/programming • • Apr 23 '13

PathFinding algorithm, visually explained

http://qiao.github.io/PathFinding.js/visual/
2.2k Upvotes

230 comments sorted by

View all comments

0

u/nickbenn Apr 24 '13

Cool illustration - though the corner of my eye kept twitching each time I saw Manhattan, Euclidean, and Chebyshev listed as heuristics (rather than distance metrics).

5

u/finix Apr 24 '13

Then you should go see an eye doctor, or maybe a proctologist, because the respective distances to the goal are the heuristics employed.

2

u/nickbenn Apr 24 '13 edited Apr 24 '13

Notwithstanding creeping fuzziness in usage, a distance metric is not, per se, a heuristic. It's reasonable to refer to a distance metric (or estimate) as a "heuristic function", "heuristic value", "heuristic cost function", etc., but a heuristic is – by definition – a problem-solving or decision technique, not simply a measure by which we compare alternatives in such a technique.

It's one thing for practitioners to shorten "heuristic function" or "heuristic value" to "heuristic" as a kind of informal shorthand. However, I don't think it's a good idea to do so in a presentation or illustration used for educational or explanatory purposes.

Edit: Added "(or estimate)" to first paragraph, for clarity.

1

u/finix Apr 24 '13

I'm not saying that precision is never of substantial value - quite the contrary -, but not only would I argue that in this case you're displaying a great deal of anal retentiveness for nothing but its own sake, you're also really rather wrong.

Meditate a moment over what it means when we compute "a measure by which we compare alternatives". We want to know how far from the goal the examined node is. Now, rather than coming up with the exact value, which would be 1) costly to compute and 2) defeat the purpose, we use a heuristic.

From [Wikipedia/Heuristic (computer science)](http://en.wikipedia.org/wiki/Heuristic_(computer_science)):

In computer science, artificial intelligence, and mathematical optimization, a heuristic is a technique designed for solving a problem more quickly when classic methods are too slow, or for finding an approximate solution when classic methods fail to find any exact solution. This is achieved by trading optimality, completeness, accuracy, and/or precision for speed.

You might argue that it's turtles all the way up and A*, too, is a heuristic function, but as long as your heuristic is admissible, the solution will be optimal.

TDLR: The things listed under heuristic are heuristics.