We have a formula of f=g+h wherein g is the path cost and h is the distance left to the goal.

Given that I only want to move my unit in 4 direction (N,S,E,W), my question is:

Can we consider h as an input? Because we will choose what heuristic to use? Or not because it's value is given automatically?

• I'm not sure what exactly you want to know, but the heuristic is constant for all nodes and h's value will be the result of the applied heuristic. f(expected total cost) = g(real cost from begin to node) + h(expected cost from node to end). Oct 6 '13 at 23:30
• I think if you read this question and its answer, you wouldn't need to ask this question.
– House
Oct 6 '13 at 23:41
• This is well tread ground as others have mentioned, but: -The heuristic will be dependent on the application -The path cost would be a derived input, from the inputs current location and goal. Oct 7 '13 at 3:36
• @AdamS: No, the heuristic function is not necessarily constant for all nodes (That is merely a common and simple implementation choice). When executing a ALT implementation, the heuristic is the difference of the lengths of the pre-computed path from two (or more) landmarks. See here:cs.princeton.edu/courses/archive/spr06/cos423/Handouts/GW05.pdf or search for "A-star with Triangle Inequality and Landmarks". These algorithms can speed-up A-star by 2-3 orders of magnitude, as with on-line mapping software. Oct 7 '13 at 22:34
• @AdamS: Check out my Hexgrid Utilities library for a sample implementation: hexgridutilities.codeplex.com Oct 7 '13 at 22:36