Пример #1
0
        private Position GetRandomWalkablePosition(RandomNumberGenerator rng, TestGridInfoProvider gip)
        {
            Position position;

            do
            {
                position = rng.NextPosition(gip.Bounds);
            } while (!gip.IsWalkable(position));
            return(position);
        }
Пример #2
0
        public void PrintTestedMaps()
        {
            int  xSize    = 500;
            int  ySize    = 500;
            var  density  = TestGridInfoProvider.GridDensity.Medium;
            bool hasWalls = true;
            int  seed     = 333;

            var gip = new TestGridInfoProvider(xSize, ySize, density, hasWalls, seed);

            string header = String.Format("xSize: {0}, ySize: {1}, density: {2}, walls: {3}, seed: {4}",
                                          xSize, ySize, density, hasWalls, seed);

            Console.WriteLine(header);
            Console.Write(gip.Walkability());
            Console.WriteLine();
        }
Пример #3
0
        public void LoadTest_PathfindingPerformanceAndMemoryOverhead()
        {
            int  xSize       = 500;
            int  ySize       = 500;
            var  density     = TestGridInfoProvider.GridDensity.Medium;
            bool hasWalls    = true;
            int  rngSeed     = 333;
            int  trailsCount = 100;

            var gip = new TestGridInfoProvider(xSize, ySize, density, hasWalls, rngSeed);
            var rng = new RandomNumberGenerator(rngSeed);

            IRasterLineCreator bresenham = new BresenhamLineCreator();
            var pathfinder = new Pathfinder(gip, new NaturalLineCalculator(bresenham), bresenham);
            var stopwatch  = new Stopwatch();

            var trailsToTest = new Dictionary <Position, Position>();

            for (int i = 0; i < trailsCount; i++)
            {
                Position first  = GetRandomWalkablePosition(rng, gip);
                Position second = GetRandomWalkablePosition(rng, gip);
                trailsToTest[first] = second;
            }

            Func <Position, Position, PathfindingResult>[] findersToTest =
            {
                pathfinder.FindJumpPointsWithJps,
                pathfinder.FindJumpPointsWithSpatialAstar,
            };

            MemoryCheckPoint lastCheckPoint = new MemoryCheckPoint();            // = dotMemory.Check();

            if (GC.TryStartNoGCRegion(240111000))
            {
                lastCheckPoint = RunPathfindingAndPrintResults(xSize, ySize, density, hasWalls, trailsCount, rngSeed, findersToTest, stopwatch, trailsToTest,
                                                               lastCheckPoint);
                if (GCSettings.LatencyMode == GCLatencyMode.NoGCRegion)
                {
                    GC.EndNoGCRegion();
                }
            }
        }