private void AddEmotionalReaction(AppraisalRule appraisalRule) { var name = appraisalRule.EventName; HashSet <AppraisalRule> ruleSet; if (!Rules.TryGetValue(name, out ruleSet)) { ruleSet = new HashSet <AppraisalRule>(); Rules.Add(name, ruleSet); } ruleSet.Add(appraisalRule); }
public bool Add(Name name, ConditionSet conditionSet, T value) { ConditionMapper <T> conds; if (!m_dictionary.TryGetValue(name, out conds)) { conds = new ConditionMapper <T>(); m_dictionary[name] = conds; } return(conds.Add(conditionSet, value)); }
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); }
public float GetSocialImportance(Name target, Name perspective) { ValidateEALink(); if (!target.IsPrimitive) { throw new ArgumentException("must be a primitive name", nameof(target)); } var p = m_ea.Kb.AssertPerspective(perspective); NameSearchTree <float> targetDict; if (!m_cachedSI.TryGetValue(p, out targetDict)) { targetDict = new NameSearchTree <float>(); m_cachedSI[p] = targetDict; } float value; if (!targetDict.TryGetValue(target, out value)) { value = CalculateSI(target, p); targetDict[target] = value; } return(value); }
private void AddRecord(BaseEvent record) { m_registry.Add(record.Id, record); List <uint> ids; var name = record.EventName; if (!m_typeIndexes.TryGetValue(name, out ids)) { ids = new List <uint>(); m_typeIndexes[name] = ids; } ids.Add(record.Id); }
public IEnumerable <IAction> FilterActions(Name perspective, IEnumerable <IAction> actionsToFilter) { foreach (var a in actionsToFilter) { float minSI; if (m_claimTree.TryGetValue(a.ToNameRepresentation(), out minSI)) { if (GetSocialImportance(a.Target, perspective) < minSI) { continue; } } yield return(a); } }
public void AddDialog(DialogStateAction action) { if (m_dialogDictionary.ContainsKey(action.Id)) { throw new Exception($"Duplicate Dialog State Action with the same id \"{action.Id}\""); } var key = action.BuildSpeakAction(); HashSet <DialogStateAction> set; if (!m_nameToDialogues.TryGetValue(key, out set)) { set = new HashSet <DialogStateAction>(); m_nameToDialogues.Add(key, set); } set.Add(action); m_dialogDictionary[action.Id] = action; }
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); } }
private float internal_GetSocialImportance(Name target, Name perspective) { NameSearchTree <float> targetDict; if (!m_cachedSI.TryGetValue(perspective, out targetDict)) { targetDict = new NameSearchTree <float>(); m_cachedSI[perspective] = targetDict; } float value; if (!targetDict.TryGetValue(target, out value)) { value = CalculateSI(target, perspective); targetDict[target] = value; } return(value); }