Exemplo n.º 1
0
        private Entities.Path RetraceSteps(Entities.Grid grid, Entities.GridLocation endPoint)
        {
            var resultPath = new Entities.Path();

            var currentLocation = grid[endPoint.X, endPoint.Y];
            resultPath.Add(currentLocation);

            var pathLength = currentLocation.DistanceFromStart.Value;
            for (int i = pathLength - 1; i >= 0; i--)
            {
                currentLocation = grid.LocationsAtDistance(i).SurroundingLocation(currentLocation).First();
                resultPath.Add(currentLocation);
            }

            return resultPath.Reverse();
        }