Working on my game I decided to do a generic version of the A* graph search algorithm. Below are the results. Basically pass in your start- and goal node, a neighbor funciton, a heuristic funciton (which needs to be not only admissable but also consistent) i.e. straight line distance, cost function between two nodes (the A* implementation will only pass in neighboring nodes as argument to the cost function).
Not sure if the internal use of a mutable set to keep track of the fringe and closed nodes is optimal...
Cheers,
Emil H
tack sa mycket foer det. (pls excuse my broken Swedish, it's been a long time)
SvaraRadera