/// <summary> /// Find a solution to a map. /// </summary> /// <param name="map">Map to solve.</param> /// <param name="strategy">Strategy to use to solve the map.</param> /// <returns></returns> public static MapPath FindPath( Map map, ITraversalStrategy strategy, string options = null) { return new MapPath(strategy.Traverse(map, options)); }
/// <summary> /// Find a solution to a map. /// </summary> /// <param name="map">Map to solve.</param> /// <param name="strategy">Strategy to use to solve the map.</param> /// <returns></returns> public static MapPath FindPath( Map map, ITraversalStrategy strategy, string options = null) { return(new MapPath(strategy.Traverse(map, options))); }
public object RunTraversal(IAstVisitor visitor, ITraversalStrategy strategy) { visitor.StartSession(Expression); object traversalResult; try { strategy.Initialize(Expression); while (strategy.HasNext()) { try { var current = strategy.Next(); current.Accept(visitor); } catch (RestartTraversalException rte) { // Expression.Analyze(new TreeDumper()); strategy.Restart(rte.Root); } } } finally { traversalResult = visitor.FinishSession(); } return traversalResult; }
public INode <T> TrySearch <T>(IGeneralTree <T> tree, int nodeId, ITraversalStrategy traverser) { var searchVisitor = new SearchByNodeIdVisitor <T> { SearchId = nodeId }; traverser.Traverse(tree, searchVisitor); return(searchVisitor.FoundNode); }
public void FindPathWithBreadthFirstStrategy() { Map map; ITraversalStrategy strategy = Strategies.BreadthFirst; MapPath solution; map = new Map(this.simpleMap); solution = PathFinder.FindPath(map, strategy); PathFinder.OutputBitmap(solution, map, "simpleSolution.png"); Assert.IsNotNull(solution); map = new Map(this.largeMap); solution = PathFinder.FindPath(map, strategy); PathFinder.OutputBitmap(solution, map, "largeSolution.png"); Assert.IsNotNull(solution); // TODO: Technically, this fails, because the path goes through // some diagonal walls. map = new Map(this.organicMap); solution = PathFinder.FindPath(map, strategy); PathFinder.OutputBitmap(solution, map, "organicSolution.png"); Assert.IsNotNull(solution); }
public BinaryTree() { _traversalStrategy = new InOrderTraversal <T>(); }
public void SetTraversalStrategy(ITraversalStrategy <T> traversalStrategy) { _traversalStrategy = traversalStrategy; }
public BinaryTree(ITraversalStrategy <T> traversalStrategy) { SetTraversalStrategy(traversalStrategy); }
public BinaryTree(ITraversalStrategy <T> traversalStrategy) { _traversalStrategy = traversalStrategy ?? throw new ArgumentNullException(nameof(traversalStrategy)); }
public TestTraversal(ITraversalStrategy traversalStrategy, Bytecode bytecode) { TraversalStrategies.Add(traversalStrategy); Bytecode = bytecode; }
private IEnumerable <T> Traverse(ITraversalStrategy <T> strategy) { return(strategy.Traverse(Root)); }
public new IList<Cell> GetNeighbors(Cell node, ITraversalStrategy<Cell> agent) { if (!(agent is IGridTraversalStrategy)) throw new ArgumentException(String.Format(Strings.ArgumentTypeMismatch, typeof(IGridTraversalStrategy))); return GetNeighbors(node, (IGridTraversalStrategy)agent); }
public List<Cell> NeighborsPassableBy(ITraversalStrategy<Cell> agent) { return (List<Cell>)Grid.GetNeighbors(this, agent); }