Exemple #1
0
        public Distances PathToGoal(Cell goal)
        {
            var current = goal;

            var breadcrumbs = new Distances(root);

            breadcrumbs[current] = cells[current];

            do
            {
                foreach (Cell neighbor in current.Links)
                {
                    if (cells[neighbor] < cells[current])
                    {
                        breadcrumbs[neighbor] = cells[neighbor];
                        current = neighbor;
                        break;
                    }
                }
            } while(current != root);

            return(breadcrumbs);
        }
Exemple #2
0
        public Distances PathToGoal(Cell goal)
        {
            var current = goal;

            var breadcrumbs = new Distances(root);
            breadcrumbs[current] = cells[current];

            do
            {
                foreach (Cell neighbor in current.Links)
                {
                    if (cells[neighbor] < cells[current])
                    {
                        breadcrumbs[neighbor] = cells[neighbor];
                        current = neighbor;
                        break;
                    }
                }
            } while(current != root);

            return breadcrumbs;
        }