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); }
public double this[Position position] { // The get accessor. get { if (positionMap.ContainsKey(position)) { return(positionMap[position]); } return(double.PositiveInfinity); } set { positionMap[position] = value; } }
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); }