예제 #1
0
        public void HasTest()
        {
            float[] bits          = { 0, 1 };
            var     knowledgeBits = new KnowledgeBits(bits, 0, -1);

            ActorKnowledge.CreateInstance(Network.ActorKnowledge, _agentId, _knowledge.EntityId, knowledgeBits);
            Assert.IsFalse(_knowledgeModel.KnowsEnough(_knowledge.EntityId, 0, 0.1F, 0));
            Assert.IsTrue(_knowledgeModel.KnowsEnough(_knowledge.EntityId, 1, 0.1F, 0));
        }
예제 #2
0
        /// <summary>
        ///     Check Knowledge required against the worker expertise
        /// </summary>
        /// <param name="knowledgeId"></param>
        /// <param name="knowledgeBit">KnowledgeBit index of the task that must be checked against worker Knowledge</param>
        /// <param name="knowledgeModel"></param>
        /// <param name="step"></param>
        /// <returns>False if the agent is On and if the knowledgeBit is not known enough</returns>
        /// <returns>True if the agent is not On or the knowledgeBit is known enough</returns>
        public bool CheckKnowledge(IAgentId knowledgeId, byte knowledgeBit, KnowledgeModel knowledgeModel, ushort step)
        {
            if (knowledgeModel == null)
            {
                throw new ArgumentNullException(nameof(knowledgeModel));
            }

            return(!IsAgentOn() || knowledgeModel.KnowsEnough(knowledgeId, knowledgeBit, ThresholdForReacting, step));
        }
예제 #3
0
        public void KnowsEnoughTest()
        {
            var knowledge4     = new Knowledge(Network, MainOrganization.Models, "1", 1);
            var actorKnowledge =
                new ActorKnowledge(_agentId, knowledge4.EntityId, KnowledgeLevel.BasicKnowledge, 0, -1);

            // Non passing test
            Assert.IsFalse(KnowledgeModel.KnowsEnough(actorKnowledge, 0, Threshold, 0));
            // Passing tests
            Assert.IsTrue(KnowledgeModel.KnowsEnough(_actorKnowledge0, 0, 0, 0));
            Assert.IsFalse(KnowledgeModel.KnowsEnough(_actorKnowledge0, 0, Threshold, 0));
            Assert.IsFalse(KnowledgeModel.KnowsEnough(_actorKnowledge0, 1, Threshold, 0));
            Assert.IsTrue(KnowledgeModel.KnowsEnough(_actorKnowledge1, 0, Threshold, 0));
            Assert.IsTrue(KnowledgeModel.KnowsEnough(_actorKnowledge1, 1, Threshold, 0));
            Assert.IsFalse(KnowledgeModel.KnowsEnough(_actorKnowledge01, 0, Threshold, 0));
            Assert.IsTrue(KnowledgeModel.KnowsEnough(_actorKnowledge01, 1, Threshold, 0));
            Assert.IsTrue(KnowledgeModel.KnowsEnough(_actorKnowledgeFloat, 0, Threshold, 0));
            Assert.IsTrue(KnowledgeModel.KnowsEnough(_actorKnowledgeFloat, 1, Threshold, 0));
        }