Ejemplo n.º 1
0
 public ComponentAppraisalFrame(InternalAppraisalFrame parentFrame, object component, short weight)
 {
     this.parentFrame = parentFrame;
     this.component   = component;
     this.weight      = weight;
     this.LastChange  = 0;
 }
        /// <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);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
 public ComponentAppraisalFrame(InternalAppraisalFrame parentFrame, object component, short weight)
 {
     this.parentFrame = parentFrame;
     this.component = component;
     this.weight = weight;
     this.LastChange = 0;
 }