/// <summary> /// Appraises a set of event strings. /// /// Durring appraisal, the events will be recorded in the asset's autobiographical memory, /// and Property Change Events will update the asset's knowledge about the world, allowing /// the asset to use the new information derived from the events to appraise the correspondent /// emotions. /// </summary> /// <param name="eventNames">A set of string representation of the events to appraise</param> public void AppraiseEvents(IEnumerable <Name> eventNames, Name perspective, IEmotionalState emotionalState, AM am, KB kb) { var appraisalFrame = new InternalAppraisalFrame(); appraisalFrame.Perspective = kb.Perspective; foreach (var n in eventNames) { var evt = am.RecordEvent(n, am.Tick); var propEvt = evt as IPropertyChangedEvent; if (propEvt != null) { var fact = propEvt.Property; var value = Name.BuildName("-"); if (propEvt.NewValue.IsPrimitive) { value = propEvt.NewValue; if (value.ToString() == "-") { var remove = kb.GetAllBeliefs().Where(x => x.Name == fact); kb.removeBelief(fact); } else { kb.Tell(fact, value, perspective); } } else // new value is not grounded { var values = kb.AskPossibleProperties(propEvt.NewValue, perspective, new List <SubstitutionSet>()); if (values.Count() == 1) { kb.Tell(fact, values.FirstOrDefault().Item1.Value, perspective); } else { throw new Exception("Multiple possible values for " + propEvt.NewValue); } } } appraisalFrame.Reset(evt); var componentFrame = appraisalFrame.RequestComponentFrame(m_appraisalDerivator, m_appraisalDerivator.AppraisalWeight); m_appraisalDerivator.Appraisal(kb, evt, componentFrame); UpdateEmotions(appraisalFrame, emotionalState, am); } }
public void AppraiseEvents(IEnumerable <Name> eventNames) { var APPRAISAL_FRAME = new InternalAppraisalFrame(); foreach (var n in eventNames) { var evtN = n.RemovePerspective(Perspective); var evt = m_am.RecordEvent(evtN, Tick); var propEvt = evt as IPropertyChangedEvent; if (propEvt != null) { var fact = propEvt.Property; var value = (Name)propEvt.NewValue; m_kb.Tell(fact, value.GetPrimitiveValue(), Name.SELF_SYMBOL); } APPRAISAL_FRAME.Reset(evt); var componentFrame = APPRAISAL_FRAME.RequestComponentFrame(m_appraisalDerivator, m_appraisalDerivator.AppraisalWeight); m_appraisalDerivator.Appraisal(this, evt, componentFrame); UpdateEmotions(APPRAISAL_FRAME); } }