Problem Understanding the logic

Just to be sure at 10:00 when Gary makes the

if (!reached.ContainsKey(neighbor.coordinates) && isWalkable
{
reached.Add(neighbor.coordinate , neighbor);

frontier.Enqueue(neighbor)
}

does this line of code mean If “reached dictionary” gets the has the key and the value of the neighbor node but has not reached it yet and also isWalkable then apply the parameters mentioned in the if statement?

is this the logic behind the code?

1 Like

Yea, it means if the reached dictionary does not have the neighbor’s coordinates, and the neighbor is walkable, run the logic

Your code looks a little different, though. I’m not sure if you copy and pasted it into the post, or just retyped it, but it should be neighbor.isWalkable

1 Like

yeah I retyped it and missed that portion thanks for the help mate!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms