6

From what I understand:

Add the current node to the closed list.

Find adjacent nodes to the current node, and if they are not unwalkable nodes and not on the closed list, add that node to the open list with the parent being the current node and calculate the F, G and H values. If the node already exists on the open list, check if going to that node through the current node will result in a lower G value - if yes, make the parent node of that node the current node.

Find the node on the open list with the highest F value, and make the current node that node.

Repeat until you end up in your destination, then go through the parents of the destination node, and you will come back to your start node. That will be the best path.

So, this makes sense to my brain, but when I actually try it out on a diagram, I think I'm not understanding it correctly.

(From the picture below) Go down from the starting green tile, the one with a F value of 60. That is on the open list, and has a lower F value than bottom-right 74 one. Why is the 74 one picked instead of the 60?

A*

apscience
  • 7,033
  • 11
  • 55
  • 89

2 Answers2

4

In my opinion, you should take a look at Amit's A* Pages. They really are great to explain how the algorithm works and how to make it work.

As for your case, the diagram shows the G score from the first node on the open list. When you look at the website, the whole diagram is built first for the first node evaluation, and the author shows that the first best node is the one to the right. Then, moving forward uses the G score based on the score of the current node plus the moving cost of the next one, which is not shown on the diagram.

It is said on the website though:

And the last square, to the immediate left of the current square, is checked to see if the G score is any lower if you go through the current square to get there. No dice.

It's G score would actually be 24 (14 (current cost) + 10 (horizontal movement cost)), just like the square below it, if I remember correctly.

Jesse Emond
  • 7,180
  • 7
  • 32
  • 37
  • Hmm? I think figured it out now. The 60 F score is the lowest, so that one is made the current node. Then it is added to the closed list. It just continues on and on until all nodes below 74 is on the closed list, and then makes the node with 74 the current square. It's like that because further down the page you can see the G score of the one two down the green node has changed, so that must mean the 60 node has being made the current square. – apscience Jun 18 '11 at 12:53
  • @gladoscc: oh well, my A* knowledge is rusty. =/ But still, I'd advice you to read the whole Amit's pages series, they'll help a lot. – Jesse Emond Jun 18 '11 at 13:13
0

The reason that you do not move to the square with an F-value of 60 is because it is in the 'closed list'. Where as the squares with an F-value of 88 and 74 are in the 'open list' and can be examined for the next move.