コード例 #1
0
        private static List <IPosition> ReconstructPath(PositionMap <Position> cameFrom, Position current)
        {
            var totalPath = new List <IPosition> {
                current
            };

            while (cameFrom.ContainsKey(current))
            {
                current = cameFrom[current];
                totalPath.Add(current);
            }
            return(totalPath);
        }
コード例 #2
0
 public double this[Position position]
 {
     // The get accessor.
     get
     {
         if (positionMap.ContainsKey(position))
         {
             return(positionMap[position]);
         }
         return(double.PositiveInfinity);
     }
     set
     {
         positionMap[position] = value;
     }
 }
コード例 #3
0
        public Position GetLowest(PositionSet openSet)
        {
            Position lowest      = null;
            bool     first       = true;
            double   lowestValue = 0;

            foreach (Position a in openSet)
            {
                if (positionMap.ContainsKey(a))
                {
                    double value = positionMap[a];
                    if (first || lowestValue < value)
                    {
                        lowest      = a;
                        lowestValue = value;
                        first       = false;
                    }
                }
            }
            return(lowest);
        }