Example #1
0
        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);
                }
            }
        }
Example #2
0
 public static Point?FindNextUnblockedMove(this IDijkstraMap dijkstra, IEnumerable <Point> nextPoints, Func <Point, bool> blocked)
 {
     nextPoints = nextPoints.OrderBy(p => dijkstra.GetCost(p));
     foreach (var next in nextPoints)
     {
         if (!blocked(next))
         {
             return(next);
         }
     }
     return(null);
 }