Why we need H?

i dont care about it… i want calculate all movement positions. using PriorityQueue and priority is the G score, H is useless here, but good to know how A* works…

The G itself only tells you how far you’ve moved, it tells you nothing of how close you are to the final goal.
That’s what the H does, it’s a heuristic, or a guess, so you can figure out which positions to prioritize.
Without the H it can still work, except you will be cycling through every single grid position instead of being smart and prioritizing nodes that are more likely to be close to the goal.

4 Likes

yes, calculate all possible movement when you select the unit,how you will calculate the movement “shadow”? like ufo, homam… ?

I’m not sure I understand what you’re asking, can you rephrase that?

Privacy & Terms