2

I'm still trying to figure out how and why my heuristics choices affect the search time of my a* implementation.

I have my map as follows ( not exact size ):

###########
#         #
# # # # # #
#         #
# # # # # #
#         #

I chose my heuristics as

option 1: h = abs(n.x - target.x) + abs(n.y - target.y)
option 2: h = 2*(abs(n.x- target.x) + abs(n.y - target.y))

with option 1, the algorithm runs relatively fine until I have to move from top to bottom, and in that case it takes long to come up with the path.

with option 2, the option 1 time is improved by around 90%.

I tried to read about overestimation/underestimation, and I couldn't come up with a clear explanation.

What could be the reason? also, are my choices reasonable?

rethabile
  • 3,029
  • 6
  • 34
  • 68
  • 1
    Why not choose a Euclidean distance? It’s been a while since I worked with this but given a 2D map space, a Euclidean distance should give an optimal heuristic. – Konrad Rudolph Aug 03 '16 at 19:30
  • You should also test heuristics with other maps too, the best heuristic would be the one that performs best by taking the average time (steps) of all maps – adhie Aug 03 '16 at 19:33
  • I would also suggest Euclidean distance, it gives a decent estimate of the remaining path, while being easily computable, therefore fast. Also, it is admissible. – adhie Aug 03 '16 at 19:43
  • @konrad I thought manhattan would be more appropriate since I can't move diagonally. – rethabile Aug 03 '16 at 19:46
  • I tried Euclidean distance and it's even worse. – rethabile Aug 04 '16 at 08:56
  • have a look at Jump Point Search – FrankS101 Sep 21 '16 at 11:07

1 Answers1

0

Take a look at this answer. There is a link to a nice tutorial that explains and gives rules of thumb about which heuristics should be chosen for different types of problems, followed by a friendly explanation of those techniques.

Community
  • 1
  • 1
marcelovca90
  • 2,673
  • 3
  • 27
  • 34