public void SeedIteratedByChangingEitherBaseSeedOrIndex()
        {
            // Check if changing the index changes the generated random state
            var iteratedIndex1 = SamplerUtility.IterateSeed(0, 0);
            var iteratedIndex2 = SamplerUtility.IterateSeed(1, 0);

            Assert.AreNotEqual(iteratedIndex1, iteratedIndex2);

            // Check if changing the seed changes the generated random state
            var iteratedSeed1 = SamplerUtility.IterateSeed(0, 0);
            var iteratedSeed2 = SamplerUtility.IterateSeed(0, 1);

            Assert.AreNotEqual(iteratedSeed1, iteratedSeed2);
        }
示例#2
0
        void Update()
        {
            // TODO: remove this check when the perception camera can capture the first frame of output
            if (m_SkipFrame)
            {
                m_SkipFrame = false;
                return;
            }

            // Wait for any final uploads before exiting quitting
            if (m_WaitingForFinalUploads && quitOnComplete)
            {
                Manager.Instance.Shutdown();
                if (!Manager.FinalUploadsDone)
                {
                    return;
                }
#if UNITY_EDITOR
                UnityEditor.EditorApplication.ExitPlaymode();
#else
                Application.Quit();
#endif
                return;
            }

            // Iterate Scenario
            if (m_FirstScenarioFrame)
            {
                m_FirstScenarioFrame = false;
            }
            else
            {
                currentIterationFrame++;
                framesSinceInitialization++;
                if (isIterationComplete)
                {
                    IncrementIteration();
                    currentIterationFrame = 0;
                    foreach (var randomizer in activeRandomizers)
                    {
                        randomizer.IterationEnd();
                    }
                }
            }

            // Quit if scenario is complete
            if (isScenarioComplete)
            {
                foreach (var randomizer in activeRandomizers)
                {
                    randomizer.ScenarioComplete();
                }
                DatasetCapture.ResetSimulation();
                m_WaitingForFinalUploads = true;
                return;
            }

            // Perform new iteration tasks
            if (currentIterationFrame == 0)
            {
                DatasetCapture.StartNewSequence();
                SamplerState.randomState = SamplerUtility.IterateSeed((uint)currentIteration, genericConstants.randomSeed);

                DatasetCapture.ReportMetric(m_IterationMetricDefinition, new[]
                {
                    new IterationMetricData()
                    {
                        iteration = currentIteration
                    }
                });
                foreach (var randomizer in activeRandomizers)
                {
                    randomizer.IterationStart();
                }
            }

            // Perform new frame tasks
            foreach (var randomizer in activeRandomizers)
            {
                randomizer.Update();
            }
        }
示例#3
0
 /// <summary>
 /// Resets SamplerState.randomState with a new seed value generated by hashing this Scenario's randomSeed
 /// with its currentIteration
 /// </summary>
 protected virtual void ResetRandomStateOnIteration()
 {
     SamplerState.randomState = SamplerUtility.IterateSeed((uint)currentIteration, genericConstants.randomSeed);
 }