Ejemplo n.º 1
0
        //////////////////////////////////////////////////////////////////////////
        public void Init(FindPathOptions options, iExplorer <T> exlorer, T start, T[] goal)
        {
            if (Result == FindPathResult.None)
            {
                // save data
                Options  = options;
                Explorer = exlorer;
                Start    = start;
                Goal     = goal;

                // set running state
                Result = FindPathResult.Running;


                // allocate collections
                Path        = new LinkedList <T>();
                OpenSet     = new FastPriorityQueue <PathNode <T> >(Pathfinder.c_AdaptiveBufferExperiance.Average);
                ClosedSet   = new HashSet <T>();
                ClosedNodes = new LinkedList <PathNode <T> >();

                // create start node, add to open set
                var startNode = new PathNode <T>(start)
                {
                    СameFrom          = null,
                    PathCost          = 0.0f,
                    PathCostEstimated = 0.0f,
                    Cost = 0.0f
                };

                OpenSet.Enqueue(startNode, startNode.Cost);
            }
        }
Ejemplo n.º 2
0
 public AStarSearch(IGridProvider grid)
 {
     _grid = grid;
     _open = new FastPriorityQueue(_grid.Size.X * _grid.Size.Y);
 }