Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
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);
            }
        }