I am not certain about what is going on here, but there are some issues with the code which are making things unnecessarily complicated.
inter = fscore /@ start;
minimum = Position[inter, Min[inter]];
current = openset[[minimum]];
This is giving you unwanted nesting, and possibly more than one minimum. Position[list, minimum]
returns the list of positions of all occurrences of minimum. One possibility is to use RandomChoice
, another is Position[list,minimum][[1]]
Nesting of lists is not in the pseudo-code so your code will be closer to what is on the wikipedia.
About your question in specific, the Wolfram Language function If
works the way you would expect. It doesn't do anything funny.
Aside, I don't see the equivalent of " remove current from openset" or "add current to closedset"
The modern way to approach these sorts of problems is to take advantage of a builtin function like FindShortestPath