コード例 #1
0
 public void InitializeExpertiseTest1()
 {
     _cognitiveArchitecture.KnowledgeAndBeliefs.HasInitialKnowledge = true;
     _knowledgeModel.AddKnowledge(_knowledge.EntityId, new float[] { 0 }, 0, -1);
     _knowledgeModel.InitializeExpertise(0);
     Assert.IsNotNull(_knowledgeModel.GetActorKnowledge(_knowledge.EntityId).KnowledgeBits);
 }
コード例 #2
0
        /// <summary>
        ///     Check Knowledge required by a task against the worker expertise
        /// </summary>
        /// <param name="knowledgeId"></param>
        /// <param name="taskBitIndexes">KnowledgeBits indexes of the task that must be checked against worker Knowledge</param>
        /// <param name="knowledgeModel"></param>
        /// <param name="mandatoryCheck"></param>
        /// <param name="requiredCheck"></param>
        /// <param name="mandatoryIndex"></param>
        /// <param name="requiredIndex"></param>
        /// <param name="step"></param>
        public void CheckKnowledge(IAgentId knowledgeId, TaskKnowledgeBits taskBitIndexes,
                                   KnowledgeModel knowledgeModel,
                                   ref bool mandatoryCheck,
                                   ref bool requiredCheck, ref byte mandatoryIndex, ref byte requiredIndex, ushort step)
        {
            if (taskBitIndexes is null)
            {
                throw new ArgumentNullException(nameof(taskBitIndexes));
            }

            if (knowledgeModel == null)
            {
                throw new ArgumentNullException(nameof(knowledgeModel));
            }

            // model is off
            if (!IsAgentOn())
            {
                mandatoryCheck = true;
                requiredCheck  = true;
                return;
            }

            // agent may don't have the knowledge at all
            var actorKnowledge = knowledgeModel.GetActorKnowledge(knowledgeId);

            if (actorKnowledge == null)
            {
                return;
            }

            mandatoryCheck = knowledgeModel.Check(actorKnowledge, taskBitIndexes.GetMandatory(), out mandatoryIndex,
                                                  ThresholdForReacting, step);
            requiredCheck = knowledgeModel.Check(actorKnowledge, taskBitIndexes.GetRequired(), out requiredIndex,
                                                 ThresholdForReacting, step);
        }