public Point?GetNext(string type, Point pos, DijkstraNeighbors neighbors, Random random) { var map = Get(type); var nextMoves = map.FindNextMoves(pos, neighbors); return(map.FindNextUnblockedMove(nextMoves.Shuffle(random), IsBlocked)); }
public static IEnumerable <Point> FindNextMoves(this IDijkstraMap dijkstra, Point start, DijkstraNeighbors neighbors) { double minDist = dijkstra.GetCost(start); foreach (var neighbor in neighbors(start)) { double dist = dijkstra.GetCost(neighbor); if (dist < minDist) { yield return(neighbor); } } }