public override void _Ready() { Node n = this; Node rootNode = GetNode("/root"); while (agent == null && n != rootNode) { Node parent = n.GetParent(); n = parent; agent = parent as RLAgent; } if (resettable) { agent.AddResetListener(this); } if (usePathAsID) { this.id = GetPath(); } else { this.id = Name; } OnCreate(); }
public void Check(Collider collider) { RLAgent agent = collider.gameObject.GetComponent<RLAgent>(); if (agent != null) { touched[agent.Id] = true; agent.touchListener(this); if (precondition != null) { if (!precondition.allowNext || !precondition.wasTouched(agent)){ agent.AddReward(-painForViolatinPrecondition, this); agent.PreconditionFailListener(this, precondition); return; } } if (multiplePreconditions != null) { if (!multiplePreconditions.allowNext || !multiplePreconditions.wasTouched(agent)) { agent.AddReward(-painForViolatinPrecondition, this); agent.PreconditionFailListener(this, multiplePreconditions); return; } } if ( (counter[agent.Id] < maxTouch) || (maxTouch < 0) ) { counter[agent.Id]++; agent.AddReward(rewardValue, this); } else if (maxTouch >= 0 && counter[agent.Id] >= maxTouch) { agent.AddReward(-painForOverTouch, this); } } }
private void Check(Collider collider) { RLAgent agent = collider.gameObject.GetComponent <RLAgent>(); agent.boxListener(this); if (counter[agent.Id] < maxNumberOfTheRewards || maxNumberOfTheRewards < 0) { if (checkInside) { Collider[] colliders = Physics.OverlapBox(myCollider.bounds.center, myCollider.bounds.extents, transform.rotation); int idx = System.Array.IndexOf(colliders, collider); if (idx >= 0) { counter[agent.Id]++; agent.AddReward(rewardValue, this); } } else { counter[agent.Id]++; agent.AddReward(rewardValue, this); } } }
public bool wasTouched(RLAgent agent) { if (this.preconditions != null && this.preconditions.Length > 0) { bool r = true; foreach (TouchRewardFunc t in preconditions) { if (atLeastOne) { r = false; if (t.wasTouched(agent)) { return(true); } } else { if (!t.wasTouched(agent)) { return(false); } } } return(r); } else { return(true); } }
public void Start() { if (target == null) { Debug.LogWarning("ForwardTargetReward error: target don't specified!"); } agent = GetComponent <RLAgent>(); agent.AddResetListener(this); minDist = -1; }
void OnCollisionExit(Collision other) { if (triggerOnExit) { RLAgent agent = other.gameObject.GetComponent <RLAgent>(); agent.boxListener(this); counter[agent.Id]++; agent.AddReward(rewardValue, this); } }
public override void RewardFrom(string actionName, RLAgent agent) { float d = Vector3.Distance(transform.localPosition, target.transform.localPosition); if (minDist >= 0) { agent.AddReward(Math.Max(minDist - d, 0) - penalityByAction); } if (minDist < 0 || minDist > d) { minDist = d; } }
void Start() { if (ignoreX) { fx = 0; } else { fx = 1; } if (ignoreY) { fy = 0; } else { fy = 1; } if (ignoreZ) { fz = 0; } else { fz = 1; } f = new Vector3(fx, fy, fz); hist = new float[samples]; head = 0; len = 0; totalReceivedReward = 0.0f; agent = GetComponent <RLAgent>(); agent.AddResetListener(this); prevPosition = transform.localPosition; if (samples <= 0) { Debug.LogWarning("Warning: the field samples value must be greater than 0!!!"); } if (target == null) { Debug.LogWarning("Warning: target is not specified for reward function named AutoApproximationReward."); } }
// Start is called before the first frame update void Start() { if (ignoreX) { fx = 0; } else { fx = 1; } if (ignoreY) { fy = 0; } else { fy = 1; } if (ignoreZ) { fz = 0; } else { fz = 1; } f = new Vector3(fx, fy, fz); prevPosition = transform.localPosition; agent = GetComponent <RLAgent>(); agent.AddResetListener(this); sumOfRewards = 0; }
private void Check(Collider collider) { RLAgent agent = collider.gameObject.GetComponent <RLAgent>(); if (precondition != null) { if (!precondition.allowNext || !precondition.wasTouched(agent)) { agent.AddReward(-painForViolatinPrecondition, this); return; } } if ((counter[agent.Id] < maxTouch || maxTouch < 0)) { counter[agent.Id]++; agent.AddReward(rewardValue, this); } else if (maxTouch >= 0 && counter[agent.Id] >= maxTouch) { agent.AddReward(-painForOverTouch, this); } }
public virtual void RewardFrom(string actionName, RLAgent agent) { }
public bool wasTouched(RLAgent agent) { return touched[agent.Id]; }
public virtual void RewardFrom(RLAgent agent) { }
void Start() { fall = false; agent = GetComponent <RLAgent>(); agent.AddResetListener(this); }
public bool wasTouched(RLAgent agent) { return(counter[agent.Id] >= precondictionMin); }