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 }; }
internal void StopProducing() { State = ObservableState.Stopping; if (WorkingThread.IsAlive) { WorkingThread.Join(); } }
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); } } }
public PartiallyObservableState(ObservableState observableState, NonObservableState nonObservableState) { this.ObservablePart = observableState; this.NonObservablePart = nonObservableState; this.IdToken = this.ObservablePart.IdToken + this.NonObservablePart.IdToken; }
public ParentMatch(int indent, ObservableState state) { Indent = indent; State = state; }
public FindObservableStateVisitor() { Result = new ObservableState(); }