示例#1
0
    // Resets the agent. Initialize the style animator and master if not initialized.
    public override void AgentReset()
    {
        if (!_hasLazyInitialized)
        {
            _master            = GetComponent <StyleTransfer002Master>();
            _master.BodyConfig = MarathonManAgent.BodyConfig;
            _decisionRequester = GetComponent <DecisionRequester>();
            var spawnableEnv = GetComponentInParent <SpawnableEnv>();
            _localStyleAnimator       = spawnableEnv.gameObject.GetComponentInChildren <StyleTransfer002Animator>();
            _styleAnimator            = _localStyleAnimator.GetFirstOfThisAnim();
            _styleAnimator.BodyConfig = MarathonManAgent.BodyConfig;

            _styleAnimator.OnInitializeAgent();
            _master.OnInitializeAgent();

            _hasLazyInitialized = true;
            _localStyleAnimator.DestoryIfNotFirstAnim();
        }
        _isDone = true;
        _ignorScoreForThisFrame = true;
        _master.ResetPhase();
        _sensors = GetComponentsInChildren <SensorBehavior>()
                   .Select(x => x.gameObject)
                   .ToList();
        SensorIsInTouch = Enumerable.Range(0, _sensors.Count).Select(x => 0f).ToList();
        if (_scoreHistogramData != null)
        {
            var column = _master.StartAnimationIndex;
            if (_decisionRequester?.DecisionPeriod > 1)
            {
                column /= _decisionRequester.DecisionPeriod;
            }
            if (_ignorScoreForThisFrame)
            {
                _ignorScoreForThisFrame = false;
            }
            else
            {
                _scoreHistogramData.SetItem(column, AverageReward);
            }
        }
    }
示例#2
0
 public override void AgentReset()
 {
     _ignorScoreForThisFrame = true;
     _master.ResetPhase();
     _sensors = GetComponentsInChildren <SensorBehavior>()
                .Select(x => x.gameObject)
                .ToList();
     SensorIsInTouch = Enumerable.Range(0, _sensors.Count).Select(x => 0f).ToList();
     if (_scoreHistogramData != null)
     {
         var column = _master.StartAnimationIndex / agentParameters.numberOfActionsBetweenDecisions;
         if (_ignorScoreForThisFrame)
         {
             _ignorScoreForThisFrame = false;
         }
         else
         {
             _scoreHistogramData.SetItem(column, AverageReward);
         }
     }
 }