Exemple #1
0
        public void InitAg()
        {
            if (bb == null)
            {
                new BeliefBase();
            }

            if (pl == null)
            {
                pl = new PlanLibrary();
            }

            if (initialDesires == null)
            {
                initialDesires = new List <Literal>();
            }

            if (initialBeliefs == null)
            {
                initialBeliefs = new List <Literal>();
            }

            if (internalActions == null)
            {
                internalActions = new Dictionary <string, InternalAction>();
            }

            //if (! "false".equals(Config.get().getProperty(Config.START_WEB_MI))) MindInspectorWeb.get().registerAg(this);
        }
Exemple #2
0
 // Start is called before the first frame update
 public override void Start()
 {
     bob  = Agent.Create(new AgentArchitecture(), "", new Runtime.Settings()); //aqui de alguna manera creo un agente que diga hola
     bb   = new BeliefBase();
     pl   = new PlanLibrary();
     lamp = lightbulb.GetComponent <Lamp>();
     lightOnAgentScript  = lightOnAgent.GetComponent <LightOnAgent>();
     lightOffAgentScript = lightOffAgent.GetComponent <LightOffAgent>();
 }
        private void ChoosePlan()
        {
            var primaryIntention = Intentions.Pop();
            var location         = primaryIntention.Predicate as Tuple <int, int>;

            switch (primaryIntention.Name)
            {
            case TypesDesire.Dig:
                CurrentPlan = PlanLibrary.First(p => p.Name == TypesPlan.PathFinding);
                CurrentPlan.BuildPlan(new Tuple <int, int>(X, Y), location);
                break;
            }
        }
Exemple #4
0
        public virtual KeyValuePair <Event, int> FindEventForFailure(Trigger tevent, PlanLibrary pl, Circumstance c)
        {
            Trigger failTrigger           = new Trigger(TEOperator.del, tevent.GetTEType(), tevent.GetLiteral());
            IEnumerator <IntendedPlan> ii = GetEnumerator();
            int posInStak = Size();

            // synchronized (pl.GetLock())
            while (!pl.HasCandidatePlan(failTrigger) && ii.MoveNext())
            {
                IntendedPlan ip = ii.Current;
                tevent      = ip.GetTrigger();
                failTrigger = new Trigger(TEOperator.del, tevent.GetTEType(), tevent.GetLiteral());
                posInStak--;
            }
            if (tevent.IsDesire() && tevent.IsAddition() && pl.HasCandidatePlan(failTrigger))
            {
                return(new KeyValuePair <Event, int>(new Event(failTrigger.Clone(), this), posInStak));
            }
            else
            {
                return(new KeyValuePair <Event, int>(null, 0));
            }
        }
Exemple #5
0
            public override KeyValuePair <Event, int> FindEventForFailure(Trigger tevent, PlanLibrary pl, Circumstance c)
            {
                KeyValuePair <Event, int> t = (KeyValuePair <Event, int>)base.FindEventForFailure(tevent, pl, c);

                if (t.Value <= forkPoint)
                {
                    if (fd.isAnd)
                    {
                        fd.intentions.Remove(this);
                        foreach (Intention ifo in fd.intentions)
                        {
                            c.DropIntention(ifo);
                        }
                    }
                    else
                    {
                        return(new KeyValuePair <Event, int>(null, t.Value));
                    }
                }
                return(t);
            }
Exemple #6
0
 public void SetPL(PlanLibrary pl)
 {
     this.pl = pl;
 }
Exemple #7
0
 private void Delete(Plan plan)
 {
     plan.Triggered -= PlanOnTriggered;
     PlanLibrary.Delete(BitConverter.GetBytes(plan.ObjectId));
     _idToPlan.Remove(plan.ObjectId, out _);
 }
Exemple #8
0
        private void Update(Plan plan)
        {
            var bytes = MessagePackSerializer.Serialize(plan, SerializerOptions);

            PlanLibrary.Put(BitConverter.GetBytes(plan.ObjectId), bytes);
        }