Exemplo n.º 1
0
        public void ObserveVerb(ushort entityID, ushort targetID, ushort verbID, float verbIntensity, SortedList <ushort, Reaction> reactions)
        {
            verbIntensity *= ED.Number * 2;
            if (entityID != EntityID)
            {
                Perception perception = null;

                Reaction reaction = null;
                if (Perceptions.TryGetValue(entityID, out perception))
                {
                    VerbTargetInfo targetInfo = new VerbTargetInfo(targetID);

                    var globalPerceptions = Perceptions[0].TotalPerceptions / (Perceptions.Count - 1);
                    var entityPerceptions = Perceptions[EntityID].TotalPerceptions;
                    targetInfo.KnowThemWell = new BoundedNumber(entityPerceptions - globalPerceptions);
                    if (entityPerceptions <= globalPerceptions)
                    {
                        targetInfo.UsingGlobalPerceptions = true;
                    }

                    float verbIntensityTemp = verbIntensity;
                    if (targetID != EntityID) // you are not the target
                    {
                        //verbIntensityTemp *= verbIntensity;
                        targetInfo.GetTraits = () => new Perception[] { Perceptions[EntityID], Perceptions[targetID], Perceptions[entityID], Perceptions[0] };
                    }
                    else
                    {
                        targetInfo.IsYou     = true;
                        targetInfo.GetTraits = () => new Perception[] { Perceptions[EntityID], Perceptions[targetID], Perceptions[0] };
                    }
                    reaction = perception.ObserveVerb(verbID, targetInfo, this, verbIntensity);
                }
                else
                {
                    //if (notTarget && !Perceptions.ContainsKey(targetID))
                    // first impressions are made automatically upon being made observable
                    (perception, reaction) = Perception.FromFirstImpression(Constants.CHARACTERS[targetID], Perceptions[0], verbID, targetID, targetID != EntityID, verbIntensity, this);
                    Perceptions.Add(entityID, perception);
                }

                if (reaction == null)
                {
                    Emotions.Apathy_Passion -= 0.5f * ED.Number;
                }
                else
                {
                    reactions.Add(EntityID, reaction);
                }
            }

            // TODO: Affects self-perceptions
        }
Exemplo n.º 2
0
        /// <summary>
        /// Implementation of the activity
        /// </summary>
        /// <param name="context">The context used to schedule</param>
        protected override HiddenMarkovModel Execute(CodeActivityContext context)
        {
            List <String>   statesList = States.ToList <String>();
            RandomVariable  prior      = new RandomVariable(statesList);
            TransitionModel tm         = new TransitionModel(States.ToList <String>());

            foreach (Triplet <string, string, double> transitionProbability in TransitionProbabilities)
            {
                tm.setTransitionProbability(transitionProbability.First, transitionProbability.Second, transitionProbability.Third);
            }

            SensorModel sm = new SensorModel(States.ToList <String>(), Perceptions.ToList <String>());

            foreach (Triplet <string, string, double> sensingProbability in SensingProbabilities)
            {
                sm.setSensingProbability(sensingProbability.First, sensingProbability.Second, sensingProbability.Third);
            }
            HiddenMarkovModel result = new HiddenMarkovModel(prior, tm, sm);

            return(result);
        }
Exemplo n.º 3
0
 protected override void InObjectLoad()
 {
     Perceptions.InObjectLoad(FilePath);
 }
Exemplo n.º 4
0
 public override void Save()
 {
     Perceptions.Save(FilePath);
 }