Exemple #1
0
        private void PlayModeChange()
        {
            if (_started && !EditorApplication.isPlayingOrWillChangePlaymode && EditorApplication.isPlaying)
            {
                // Stop is called within the playmode scene

                if (_currentStory != null)
                {
                    Debug.Log("Saving imiation data");
                    var imitation = QAIManager.SaveImitation("Imitation set " + (_currentStory.ImitationExperiences.Count + 1));
                    _currentStory.ImitationExperiences.Add(imitation);
                    _currentStory.Save(STORY_PATH);
                }
                _currentStory = null;
            }
            if (_started && !EditorApplication.isPlaying)
            {
                // Stop is called within the editor scene
                _started = false;

                // Do something that should happen on stop
                _init = false;
                Init();

                _mode = QAIMode.Runnning;
                _manager.ModeOverride = _mode;
                _currentStory         = null;

                _learningStory++;
                if (_learnAllStories && _learningStory < _stories.Count)
                {
                    Debug.Log("Starting next learning story");
                    _remake     = false;
                    _forceStart = true;
                    _mode       = QAIMode.Learning;
                }
                else
                {
                    _learnAllStories = false;
                    _benchmark       = false;
                    _learningStory   = 0;
                    _remake          = false;
                }
            }
            if (_starting && EditorApplication.isPlaying)
            {
                // Start is called within the playmode scene
                _starting = false;
                _started  = true;

                // Do something that should happen on start
            }
        }
Exemple #2
0
 public static void InitAgent(QAgent agent, QOption option = null)
 {
     option = option ?? new QOption();
     if (_instance == null)
     {
         _instance = FindObjectOfType <QAIManager>();
         _instance.Init(agent, option);
     }
     BenchmarkSave.SaveBenchmarks = _instance.Benchmark;
     _instance._sceneIsOver       = false;
     _instance._testIsOver        = false;
     Agent = agent;
     if (_instance.Mode != QAIMode.Imitating)
     {
         _instance._qlearning.Reset(agent);
     }
 }
Exemple #3
0
        private void Init()
        {
            if (_init)
            {
                return;
            }
            _init = true;

            _manager = CreateManager();
            _agent   = _manager.ActiveAgent;
            _tester  = _manager.Tester;
            _mode    = _manager.Mode;
            _remake  = _manager.Remake;
            _term    = _manager.Terminator;
            Directory.CreateDirectory(STORY_PATH);
            _stories      = QStory.LoadForScene(STORY_PATH, EditorApplication.currentScene); // Should read this when serialization works
            _currentStory = _currentStory == null ? null : _stories.Find(s => s.Id == _currentStory.Id);
            _benchmark    = _manager.Benchmark;
        }