Пример #1
0
 public Grid(int width, int height, SadConsole.Console screen)
 {
     _renderConsole = screen;
     Width          = width;
     Height         = height;
     _cells         = new GridCell[width * height];
     _entities      = new List <Entity>();
     FieldOfView    = new ArrayMap <bool>(Width, Height);
     Walkability    = new ArrayMap <bool>(Width, Height);
     PathFinder     = new FastAStar(Walkability, Distance.MANHATTAN);
 }
Пример #2
0
        public void GlobalSetup()
        {
            var map = new Generator(PathDistance + 5, PathDistance + 5)
                      .ConfigAndGenerateSafe(gen => gen.AddSteps(DefaultAlgorithms.RectangleMapSteps()))
                      .Context.GetFirst <IGridView <bool> >("WallFloor");

            // A couple points exactly PathDistance apart.  We keep the paths on the same y-line so that they are
            // PathDistance apart regardless of the DistanceCalc.
            // Path performance checks will independently path both from p1 to p2 and from p2 to p1, in order to
            // account for one direction likely being faster (first direction checked in the neighbors loop)
            _p1 = (1, 5);
            _p2 = (PathDistance + 1, 5);

            // An AStar instance to use for pathing
            _aStar = new GoRogue.Pathing.AStar(map, DistanceCalc);

            // Equivalent FastAStar instance
            _fastAStar = new FastAStar(map, DistanceCalc);
        }
Пример #3
0
        public static TimeSpan TimeForFastAStar(int mapWidth, int mapHeight, int iterations)
        {
            var s = new Stopwatch();

            var map = new ArrayMap <bool>(mapWidth, mapHeight);

            QuickGenerators.GenerateRectangleMap(map);

            var pather = new FastAStar(map, Distance.CHEBYSHEV);
            var path   = pather.ShortestPath(START, END);           // Cache warmup

            s.Start();
            for (int i = 0; i < iterations; i++)
            {
                path = pather.ShortestPath(START, END);
            }
            s.Stop();

            return(s.Elapsed);
        }
Пример #4
0
 public MoveAction(GameMap map) : base(map)
 {
     AStar = new FastAStar(map.WalkabilityView, Distance.CHEBYSHEV);
 }