Beispiel #1
0
        public static void StressTestZone(ZoneData zone, int zoneIndex, int amount)
        {
            ExampleDebug.Printing = -1;
            int   structureIndex = 0;
            ulong zoneSeed       = 0;
            int   floor          = 0;

            try
            {
                List <List <TimeSpan> > generationTimes = new List <List <TimeSpan> >();
                for (int ii = 0; ii < zone.Segments.Count; ii++)
                {
                    generationTimes.Add(new List <TimeSpan>());
                }

                Stopwatch watch = new Stopwatch();

                for (int ii = 0; ii < amount; ii++)
                {
                    zoneSeed = MathUtils.Rand.NextUInt64();
                    ReNoise totalNoise = new ReNoise(zoneSeed);

                    for (int nn = 0; nn < zone.Segments.Count; nn++)
                    {
                        structureIndex = nn;
                        ZoneSegmentBase structure = zone.Segments[nn];

                        ulong[]        doubleSeed  = totalNoise.GetTwoUInt64((ulong)structureIndex);
                        ZoneGenContext zoneContext = CreateZoneGenContextSegment(doubleSeed[0], zoneIndex, structureIndex, structure);

                        INoise idNoise = new ReNoise(doubleSeed[1]);

                        foreach (int floorId in structure.GetFloorIDs())
                        {
                            floor = floorId;
                            zoneContext.CurrentID = floorId;
                            zoneContext.Seed      = idNoise.GetUInt64((ulong)floorId);

                            TestFloor(watch, structure, zoneContext, null, null, generationTimes[nn]);
                        }
                    }
                }

                PrintTimeAnalysisTier2(generationTimes, "S");
            }
            catch (Exception ex)
            {
                DiagManager.Instance.LogInfo("ERROR at S" + structureIndex + " F" + floor + " ZSeed:" + zoneSeed);
                PrintError(ex);
            }
            finally
            {
                ExampleDebug.Printing = 0;
            }
        }
Beispiel #2
0
        public static ZoneGenContext CreateZoneGenContext(ulong zoneSeed, int zoneIndex, SegLoc floorIndex, ZoneSegmentBase structure)
        {
            ReNoise totalNoise = new ReNoise(zoneSeed);

            ulong[]        doubleSeed = totalNoise.GetTwoUInt64((ulong)floorIndex.Segment);
            ZoneGenContext newContext = CreateZoneGenContextSegment(doubleSeed[0], zoneIndex, floorIndex.Segment, structure);

            INoise idNoise = new ReNoise(doubleSeed[1]);

            newContext.CurrentID = floorIndex.ID;
            newContext.Seed      = idNoise.GetUInt64((ulong)floorIndex.ID);

            return(newContext);
        }
Beispiel #3
0
        public static void StressTestStructure(ZoneSegmentBase structure, int zoneIndex, int structureIndex, int amount)
        {
            ExampleDebug.Printing = -1;
            ulong zoneSeed = 0;
            int   floor    = 0;

            try
            {
                List <Dictionary <int, int> > generatedItems   = new List <Dictionary <int, int> >();
                List <Dictionary <int, int> > generatedEnemies = new List <Dictionary <int, int> >();
                List <List <TimeSpan> >       generationTimes  = new List <List <TimeSpan> >();
                for (int ii = 0; ii < structure.FloorCount; ii++)
                {
                    generatedItems.Add(new Dictionary <int, int>());
                    generatedEnemies.Add(new Dictionary <int, int>());
                    generationTimes.Add(new List <TimeSpan>());
                }

                Stopwatch watch = new Stopwatch();

                for (int ii = 0; ii < amount; ii++)
                {
                    zoneSeed = MathUtils.Rand.NextUInt64();

                    ReNoise totalNoise = new ReNoise(zoneSeed);
                    ulong[] doubleSeed = totalNoise.GetTwoUInt64((ulong)structureIndex);
                    INoise  idNoise    = new ReNoise(doubleSeed[1]);

                    ZoneGenContext zoneContext = CreateZoneGenContextSegment(doubleSeed[0], zoneIndex, structureIndex, structure);

                    foreach (int floorId in structure.GetFloorIDs())
                    {
                        floor = floorId;
                        zoneContext.CurrentID = floorId;
                        zoneContext.Seed      = idNoise.GetUInt64((ulong)floorId);

                        TestFloor(watch, structure, zoneContext, generatedItems[floorId], generatedEnemies[floorId], generationTimes[floorId]);
                    }
                }


                Dictionary <int, int> totalGeneratedItems   = new Dictionary <int, int>();
                Dictionary <int, int> totalGeneratedEnemies = new Dictionary <int, int>();
                for (int ii = 0; ii < structure.FloorCount; ii++)
                {
                    DiagManager.Instance.LogInfo("F" + ii + ":");
                    PrintContentAnalysis(generatedItems[ii], generatedEnemies[ii]);

                    foreach (int key in generatedItems[ii].Keys)
                    {
                        MathUtils.AddToDictionary <int>(totalGeneratedItems, key, generatedItems[ii][key]);
                    }

                    foreach (int key in generatedEnemies[ii].Keys)
                    {
                        MathUtils.AddToDictionary <int>(totalGeneratedEnemies, key, generatedEnemies[ii][key]);
                    }
                }

                DiagManager.Instance.LogInfo("Overall:");
                PrintContentAnalysis(totalGeneratedItems, totalGeneratedEnemies);

                PrintTimeAnalysisTier2(generationTimes, "F");
            }
            catch (Exception ex)
            {
                DiagManager.Instance.LogInfo("ERROR at F" + floor + " ZSeed:" + zoneSeed);
                PrintError(ex);
            }
            finally
            {
                ExampleDebug.Printing = 0;
            }
        }