I am reading about A* pathfinding using heuristics and manhattan method and I am struggling with understanding the logic in one specific place in the article.
I am stuck right after where the below image is
and to better understand here's a quote
This time, when we check the adjacent squares we find that the one to the immediate right is a wall square, so we ignore that. The same goes for the one just above that. We also ignore the square just below the wall. Why? Because you can’t get to that square directly from the current square without cutting across the corner of the nearby wall. You really need to go down first and then move over to that square, moving around the corner in the process. (Note: This rule on cutting corners is optional. Its use depends on how your nodes are placed.)
and - I have highlighted the part which confuses me
That leaves five other squares. The other two squares below the current square aren’t already on the open list, so we add them and the current square becomes their parent. Of the other three squares, two are already on the closed list (the starting square, and the one just above the current square, both highlighted in blue in the diagram), so we ignore them. 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. So we’re done and ready to check the next square on our open list.
So the author assumes that the F ( G + H ) to the immediate left is now greater than the F to the one right below. Logically, by looking at it YES, even a child will agree you should be going towards the RED so go down and across the BLUE wall, but mathematically (unless there is something obvious that I have missed) I see it this way at this point
So if I was writing out this algorithm in C# I would be stuck because both the left and bottom from "here now" would return the same number, 60? How would I know which one would I benefit from going into the most?
Even in this scenario the number would still IMO equal 60
10 to go directly left + 50 (H)
10 to go directly down + 50 (H)
Have I missed something here? What am I doing wrong?
The G cost is cumulative.
From the starting point, going south-east costs 14. From the south-east square (your "here now" square) going south costs 10, this makes for a cumulative G cost of 10+14 = 24.
Again, from the south-east square (your "here now" square) going west would cost 10 points (G) which gives us again 24 (since we already paid 14 to get to that square). But this square is already in your open list so you check if the result you just got is better. Your open list shows a G of 10 for that square and since 24 is worse you don't update it. (this is what the bold part means)