Пример #1
0
        public void Tell(Name property, Name value, Name perspective, float certainty)
		{
			if (property.IsPrimitive)
				throw new ArgumentException("The given property name cannot be a primitive value.",nameof(property));

			if (!property.IsConstant)
				throw new ArgumentException("The given property name is not constant. Only constant names can be stored",nameof(property));

			var ToMList = AssertPerspective(perspective, nameof(perspective));
			property = RemovePropertyPerspective(property, ToMList);

			//ToM property shift
			property = ExtractPropertyFromToM(property, ToMList, nameof(property));

			if (_registry.WillEvaluate(property))
				throw new ArgumentException("The given name will be obfuscated by a dynamic property", nameof(property));

			var mind_key = ToMList2Key(ToMList);

			var fact = property.ApplyToTerms(p => ApplyDynamic(p,mind_key));

			KnowledgeEntry entry;
			if (!m_knowledgeStorage.TryGetValue(fact, out entry))
			{
				entry = new KnowledgeEntry();
				m_knowledgeStorage[fact] = entry;
			}

			entry.TellValueFor(mind_key,value,certainty);
			if (entry.IsEmpty())
				m_knowledgeStorage.Remove(fact);
		}
Пример #2
0
        public void UpdateActionTemplate(Name old, Name action, int p)
        {
            var pastEffects = actions[old];

            actions.Remove(old);
            actionNames.Remove(old);

            actions.Add(action, pastEffects);

            actionNames.Add(new KeyValuePair <Name, Name>(action, action));

            priorityRules[action] = p;
        }
        public void Remove_EmptyNameSearchTree_False(string name, string value)
        {
            var tree          = new NameSearchTree <string>();
            var removeSuccess = tree.Remove(Name.BuildName(name));

            Assert.That(!removeSuccess);
        }
Пример #4
0
 public void UnregistDynamicProperty(Name propertyTemplate)
 {
     if (!m_dynamicProperties.Remove(propertyTemplate))
     {
         throw new Exception($"Unknown Dynamic Property {propertyTemplate}");
     }
 }
Пример #5
0
 public void RemoveAction(Name ActionName)
 {
     actions?.Remove(ActionName);
     if (actionNames.ContainsKey(ActionName))
     {
         actionNames.Remove(ActionName);
     }
 }
        public void Remove_NameSearchTreeThatContainsName_True(string name, string value)
        {
            var tree = new NameSearchTree <string>();

            tree.Add(Name.BuildName(name), value);
            var removeSuccess = tree.Remove(Name.BuildName(name));

            Assert.That(removeSuccess);
        }
Пример #7
0
        public void UpdateActionTemplate(Name old, Name action, int p)
        {
            var pastEffects = actions[old];

            actions.Remove(old);

            List <Effect> newEffects = new List <Effect>();

            foreach (var effs in pastEffects)
            {
                var eff = effs;
                newEffects.Add(eff);
            }
            actions.Add(action, newEffects);

            if (actionNames.ContainsKey(old))
            {
                actionNames.Remove(old);
            }
            actionNames.Add(new KeyValuePair <Name, Name>(action, action));
            priorityRules[action] = p;
        }
Пример #8
0
        public void ForgetEvent(uint eventId)
        {
            BaseEvent evt;

            if (!m_registry.TryGetValue(eventId, out evt))
            {
                return;
            }

            m_registry.Remove(eventId);
            var evts = m_typeIndexes[evt.EventName];

            evts.Remove(eventId);
            if (evts.Count == 0)
            {
                m_typeIndexes.Remove(evt.EventName);
            }
        }
Пример #9
0
        /// <summary>
        /// Adds an emotional reaction to an event
        /// </summary>
        /// <param name="emotionalAppraisalRule">the AppraisalRule to add</param>
        public void AddOrUpdateAppraisalRule(AppraisalRuleDTO emotionalAppraisalRuleDTO)
        {
            AppraisalRule existingRule     = null;
            var           existingRulePair = findExistingAppraisalRule(emotionalAppraisalRuleDTO.Id, out existingRule);

            if (existingRule == null)
            {
                this.AddEmotionalReaction(new AppraisalRule(emotionalAppraisalRuleDTO));
            }
            else
            {
                existingRule.Desirability     = emotionalAppraisalRuleDTO.Desirability;
                existingRule.Praiseworthiness = emotionalAppraisalRuleDTO.Praiseworthiness;
                existingRule.EventName        = Name.BuildName(emotionalAppraisalRuleDTO.EventMatchingTemplate);
                Rules.Remove(existingRulePair);
                Rules.Add(existingRule.EventName, existingRulePair.Value);
            }
        }
Пример #10
0
        public void Tell(Name property, PrimitiveValue value, Name perspective)
        {
            if (property.IsPrimitive)
            {
                throw new ArgumentException("The given property name cannot be a primitive value.", nameof(property));
            }

            if (!property.IsConstant)
            {
                throw new ArgumentException("The given property name is not constant. Only constant names can be stored", nameof(property));
            }

            perspective = perspective.ApplyPerspective(Perspective);
            var ToMList = AssertPerspective(perspective, nameof(perspective));

            property = RemovePropertyPerspective(property, ToMList);

            //ToM property shift
            property = ExtractPropertyFromToM(property, ToMList, nameof(property));

            if (m_dynamicProperties.Unify(property).Any())
            {
                throw new ArgumentException("The given name will be objuscated by a dynamic property", nameof(property));
            }

            var fact = property.ApplyToTerms(p => SimplifyProperty(p, ToMList));

            KnowledgeEntry entry;

            if (!m_knowledgeStorage.TryGetValue(fact, out entry))
            {
                entry = new KnowledgeEntry();
                m_knowledgeStorage[fact] = entry;
            }

            var mind_key = ToMList2Key(ToMList);

            entry.TellValueFor(mind_key, value);
            if (entry.IsEmpty())
            {
                m_knowledgeStorage.Remove(fact);
            }
        }
        public bool Remove(Name name, ConditionSet conditionSet, T value)
        {
            ConditionMapper <T> conds;

            if (!m_dictionary.TryGetValue(name, out conds))
            {
                return(false);
            }

            if (!conds.Remove(conditionSet, value))
            {
                return(false);
            }

            if (conds.Count == 0)
            {
                m_dictionary.Remove(name);
            }

            return(true);
        }
Пример #12
0
        public bool RemoveDialog(Guid id)
        {
            DialogStateAction d;

            if (!m_dialogDictionary.TryGetValue(id, out d))
            {
                return(false);
            }

            var key = d.BuildSpeakAction();
            var set = m_nameToDialogues[key];

            if (set.Remove(d))
            {
                if (set.Count == 0)
                {
                    m_nameToDialogues.Remove(key);
                }
            }
            m_dialogDictionary.Remove(id);
            return(true);
        }
 public void Remove_NameSearchTreeThatContainsName_True(string name, string value)
 {
     var tree = new NameSearchTree<string>();
     tree.Add(Name.BuildName(name), value);
     var removeSuccess = tree.Remove(Name.BuildName(name));
     Assert.That(removeSuccess);
 }
 public void Remove_EmptyNameSearchTree_False(string name, string value)
 {
     var tree = new NameSearchTree<string>();
     var removeSuccess = tree.Remove(Name.BuildName(name));
     Assert.That(!removeSuccess);
 }