Esempio n. 1
0
        public void AddBeliefTest1()
        {
            _cognitiveArchitecture.KnowledgeAndBeliefs.HasBelief = true;
            _beliefsModel.AddBelief(_belief.EntityId);
            var actorBelief = _beliefsModel.GetActorBelief(_belief.EntityId);

            Assert.IsNotNull(actorBelief);
        }
Esempio n. 2
0
        /// <summary>
        ///     Check a particular beliefId from Task.BeliefBits against Agent.Beliefs
        ///     Prevent the agent from acting on a particular belief
        ///     Task may be blocked if it is the case
        /// </summary>
        public void CheckBlockerIncompleteBelief(SymuTask task, IAgentId knowledgeId)
        {
            if (task is null)
            {
                throw new ArgumentNullException(nameof(task));
            }

            if (!Environment.MainOrganization.Murphies.IncompleteBelief.On ||
                !Environment.MainOrganization.Models.Beliefs.On)
            {
                return;
            }

            var   taskBits       = task.KnowledgesBits.GetBits(knowledgeId);
            float mandatoryScore = 0;
            float requiredScore  = 0;
            byte  mandatoryIndex = 0;
            byte  requiredIndex  = 0;

            var belief      = BeliefsModel.GetBeliefFromKnowledgeId(knowledgeId);
            var actorBelief = BeliefsModel.GetActorBelief(belief.EntityId);

            Environment.MainOrganization.Murphies.IncompleteBelief.CheckBelief(belief, taskBits, actorBelief,
                                                                               ref mandatoryScore, ref requiredScore,
                                                                               ref mandatoryIndex, ref requiredIndex);
            if (Math.Abs(mandatoryScore + requiredScore) < Tolerance)
            {
                // Check belief is ok
                return;
            }

            CheckBlockerIncompleteBelief(task, knowledgeId, mandatoryScore, requiredScore, mandatoryIndex,
                                         requiredIndex);
        }
Esempio n. 3
0
        /// <summary>
        ///     Check a particular beliefId from Task.BeliefBits against Agent.Beliefs
        ///     Prevent the agent from acting on a particular belief
        ///     Task may be blocked if it is the case
        /// </summary>
        public void CheckRiskAversion(SymuTask task, IAgentId knowledgeId)
        {
            if (task is null)
            {
                throw new ArgumentNullException(nameof(task));
            }

            if (!BeliefsModel.On)
            {
                return;
            }

            var   taskBits       = task.KnowledgesBits.GetBits(knowledgeId);
            float mandatoryScore = 0;
            byte  mandatoryIndex = 0;

            var belief      = BeliefsModel.GetBeliefFromKnowledgeId(knowledgeId);
            var actorBelief = BeliefsModel.GetActorBelief(knowledgeId);

            MurphyIncompleteBelief.CheckRiskAversion(belief, taskBits, actorBelief, ref mandatoryScore,
                                                     ref mandatoryIndex, -Cognitive.InternalCharacteristics.RiskAversionValue());
            if (!(mandatoryScore <= -Cognitive.InternalCharacteristics.RiskAversionValue()))
            {
                return;
            }

            var murphy = Environment.MainOrganization.Murphies.IncompleteBelief;

            // Prevent the agent from acting on a particular belief
            if (murphy.ShouldGuess((byte)task.HasBeenCancelledBy.Count))
            {
                // to avoid complete blocking, we allow the agent, depending on the Murphies.IncompleteBelief parameters
                // to unblock the task
                var blocker = task.Add(Murphy.IncompleteBelief, Schedule.Step, knowledgeId, mandatoryIndex);
                RecoverBlockerIncompleteBeliefByGuessing(task, blocker);
            }
            else
            {
                // Agent can cancel the task a certain number of times
                TaskProcessor.Cancel(task);
            }
        }