private Path <T> Backtrack() { List <T> path = new List <T>(); while (current.Node != startNode) { if (traverser.AddToResult(current.Node)) { path.Add(current.Node); } current = GetNodeMeta(current.Parent); } if (traverser.AddStarting && traverser.AddToResult(current.Node)) { path.Add(startNode); } path.Reverse(); return(new Path <T>(path)); }
public Area <T> GetFill(T center, int range, ITraverser <T> traverser) { this.traverser = traverser; fill.Clear(); frontier.Clear(); NodeMeta first = GetFillData(center); first.GCost = 0; frontier.Add(GetFillData(center)); for (int step = 0; step <= range; step++) { for (int i = frontier.Count - 1; i >= 0; i--) { if (frontier[i].GCost <= step) { fill.Add(frontier[i]); AddNeighbours(frontier[i]); frontier.RemoveAt(i); } } } List <T> fillResult = new List <T>(); for (int i = 0; i < fill.Count; i++) { T node = fill[i].Node; if (traverser.CanEndOn(node) && traverser.AddToResult(node)) { fillResult.Add(node); } } return(new Area <T>(fillResult)); }