Ejemplo n.º 1
0
    private IEnumerator Run()
    {
        if (lightOnReasonedLastCycle && !reasoning)
        {
            reasoning = true;
            Reasoner r = agLightOff.GetReasoner();
            textMeshS.text = agLightOff.GetName() + ": Voy a percibir mi entorno";
            Dictionary <string, string> p = r.Perceive();
            yield return(new WaitForSeconds(3));

            textMeshS.text = agLightOff.GetName() + ": Voy a actualizar mi base de creencias";
            r.UpdateBeliefs(p);
            //Desire d = ag.SelectDesire();
            yield return(new WaitForSeconds(3));

            textMeshS.text = agLightOff.GetName() + ": Voy a seleccionar un plan";
            Plan i = r.SelectPlan();
            yield return(new WaitForSeconds(3));

            textMeshS.text = agLightOff.GetName() + ": Voy a actuar";
            r.Act(i);
            lightOnReasonedLastCycle = false;
            reasoning = false;
        }
        else if (!lightOnReasonedLastCycle && !reasoning)
        {
            reasoning = true;
            Reasoner r = agLightOn.GetReasoner();
            textMeshS.text = agLightOn.GetName() + ": Voy a percibir mi entorno";
            Dictionary <string, string> p = r.Perceive();
            yield return(new WaitForSeconds(3));

            textMeshS.text = agLightOn.GetName() + ": Voy a actualizar mi base de creencias";
            r.UpdateBeliefs(p);
            //Desire d = ag.SelectDesire();
            yield return(new WaitForSeconds(3));

            textMeshS.text = agLightOn.GetName() + ": Voy a seleccionar un plan";
            Plan i = r.SelectPlan();
            yield return(new WaitForSeconds(3));

            textMeshS.text = agLightOn.GetName() + ": Voy a actuar";
            r.Act(i);
            lightOnReasonedLastCycle = true;
            reasoning = false;
        }
    }
Ejemplo n.º 2
0
        //int sumAct = 0; int nbAct = 0;
        protected void Act()
        {
            Reasoner reasoner = GetReasoner();

            int i  = 0;
            int ca = cyclesAct;

            if (ca != 1)
            { // not the default value, limit the value to the number of intentions
                ca = Math.Min(cyclesAct, reasoner.GetCircumstance().GetNbRunningIntentions());
                if (ca == 0)
                {
                    ca = 1;
                }
            }
            while (running && i++ < ca && !reasoner.CanSleepAct())
            {
                reasoner.Act();
            }
            //sumAct += i; nbAct++;
            //System.out.println("running act "+(sumAct/nbAct)+"/"+ca);
        }