コード例 #1
0
ファイル: Controller.cs プロジェクト: satpreetsingh/rat-rnn
    void FixedUpdate()
    {
        var sensors = ReadSensors();

        var utilities   = GetComponents <UtilityBase>();
        var sumPriority = utilities.Sum(u => u.priority * (u.isActiveAndEnabled ? 1: 0f));

        sumPriority = Mathf.Max(sumPriority, Mathf.Epsilon);

        Vector2 control = Vector2.zero;

        foreach (var u in utilities)
        {
            if (u.isActiveAndEnabled)
            {
                control += u.Control(sensors) * u.priority / sumPriority;
            }
        }

        body.angularVelocity = Vector3.up * Mathf.Deg2Rad * Mathf.Clamp(control.x, -1f, 1f) * turnSpeed;
        body.velocity        = transform.forward * Mathf.Clamp01(control.y) * runSpeed;

        state = new ObservableState {
            heading = Mathf.Clamp(control.x, -1f, 1f), velocity = Mathf.Clamp01(control.y),                     // in
            x       = transform.position.x, y = transform.position.y,                                           // out
            sensors = sensors                                                                                   // aux
        };
    }
コード例 #2
0
 internal void StopProducing()
 {
     State = ObservableState.Stopping;
     if (WorkingThread.IsAlive)
     {
         WorkingThread.Join();
     }
 }
コード例 #3
0
        private IEnumerable <ParentMatch> EnumerateParents(ObservableState state, int level)
        {
            //if (model.Parents.Count == 0)
            {
                yield return(new ParentMatch(level, state));
            }

            foreach (var parent in state.Parents)
            {
                foreach (var item in EnumerateParents(parent, level + 1))
                {
                    yield return(item);
                }
            }
        }
コード例 #4
0
 public PartiallyObservableState(ObservableState observableState, NonObservableState nonObservableState)
 {
     this.ObservablePart    = observableState;
     this.NonObservablePart = nonObservableState;
     this.IdToken           = this.ObservablePart.IdToken + this.NonObservablePart.IdToken;
 }
コード例 #5
0
 public ParentMatch(int indent, ObservableState state)
 {
     Indent = indent;
     State  = state;
 }
コード例 #6
0
 public FindObservableStateVisitor()
 {
     Result = new ObservableState();
 }