Exemplo n.º 1
0
        public SimpleAStarManager(int numCols, int numRows, bool isFourWay = false)
        {
            mNumCols   = numCols;
            mNumRows   = numRows;
            mIsFourWay = isFourWay;
            //mAStarHeuristic = new SimpleAStarManhattanHeuristic();
            mAStarHeuristic = new SimpleAStarDiagonalHeuristic();

            SimpleAStarNode node = null;

            mNodes = new Dictionary <string, SimpleAStarNode>();
            for (int i = 0; i < mNumCols; i++)
            {
                for (int j = 0; j < mNumRows; j++)
                {
                    node = new SimpleAStarNode(i, j);
                    node.AddCostMultiplierCallback(RefreshLinksOfAdjacentNodes);
                    mNodes.Add(GetNodeKey(i, j), node);
                }
            }
            RefreshLinksOfAllNodes();
            mBinaryHeapUtils = new BinaryHeapUtils(numCols * numRows / 2);
        }
        public SimpleAStarManager(int numCols, int numRows, bool isFourWay = false)
        {
            mNumCols = numCols;
            mNumRows = numRows;
            mIsFourWay = isFourWay;
            //mAStarHeuristic = new SimpleAStarManhattanHeuristic();
            mAStarHeuristic = new SimpleAStarDiagonalHeuristic();

            SimpleAStarNode node = null;
            mNodes = new Dictionary<string, SimpleAStarNode>();
            for (int i = 0; i < mNumCols; i++)
            {
                for (int j = 0; j < mNumRows; j++)
                {
                    node = new SimpleAStarNode(i, j);
                    node.AddCostMultiplierCallback(RefreshLinksOfAdjacentNodes);
                    mNodes.Add(GetNodeKey(i, j), node);
                }
            }
            RefreshLinksOfAllNodes();
            mBinaryHeapUtils = new BinaryHeapUtils(numCols * numRows / 2);
        }