Ejemplo n.º 1
0
 private void GenerateNode(Point tile, double distance, double moveDist, out DijkstraTile outTile, out FibonacciHeapNode <DijkstraTile, double> outNode)
 {
     outTile = new DijkstraTile(tile, distance, moveDist);
     outNode = new FibonacciHeapNode <DijkstraTile, double>(outTile, outTile.Distance);
     Tiles.Add(tile, outTile);
     NodeMap.Add(tile, outNode);
     Heap.Insert(outNode);
 }
Ejemplo n.º 2
0
        public static Point FindStart(this IDijkstraMap dijkstra, Point end)
        {
            DijkstraTile dTile = dijkstra[end.X, end.Y];

            while (dTile.Previous != null)
            {
                dTile = dTile.Previous;
            }

            return(dTile.Tile);
        }
Ejemplo n.º 3
0
        private static IEnumerable <Point> FindPathInternal(IDijkstraMap dijkstra, Point end)
        {
            DijkstraTile dTile = dijkstra[end.X, end.Y];

            while (dTile.Previous != null)
            {
                yield return(dTile.Tile);

                dTile = dTile.Previous;
            }
        }
Ejemplo n.º 4
0
        public DijkstraArray(int width, int height, FibonacciHeap <DijkstraTile, double> heap, IEnumerable <Point> starts, Rectangle activeArea)
        {
            Heap    = heap;
            Array   = new DijkstraTile[width, height];
            NodeMap = new FibonacciHeapNode <DijkstraTile, double> [width, height];

            for (int x = activeArea.X; x < activeArea.Width; x++)
            {
                for (int y = activeArea.Y; y < activeArea.Height; y++)
                {
                    Point        tile    = new Point(x, y);
                    bool         isStart = starts.Contains(tile);
                    DijkstraTile dTile   = new DijkstraTile(tile, isStart ? 0 : double.PositiveInfinity, isStart ? 0 : double.PositiveInfinity);
                    var          node    = new FibonacciHeapNode <DijkstraTile, double>(dTile, dTile.Distance);
                    Array[x, y]   = dTile;
                    NodeMap[x, y] = node;
                    Heap.Insert(node);
                }
            }
        }
Ejemplo n.º 5
0
        public static bool Reachable(this IDijkstraMap dijkstra, Point end)
        {
            DijkstraTile dTile = dijkstra[end.X, end.Y];

            return(dTile.Previous != null);
        }