示例#1
0
        }                                                     // what they are saying about the target

        /// <summary>Change perceptions upon observing someone take an expressive action.</summary>
        /// <param name="perception">   Perception of the person executing the verb.
        /// </param>
        /// <returns>     MY reaction to EXECUTER doing VERB to TARGET.
        /// </returns>
        public Reaction ApplyToPerception(Perception perception, VerbTargetInfo targetInfo, float magnitude, byte verbNumTimes)
        {
            // pSelf
            // pTarget
            // pExecutor
            // pGlobal
            Perception[] traits = targetInfo.GetTraits();
            byte         globalPerceptionsIndex = (byte)(targetInfo.IsYou ? 2 : 3);
            byte         executorIndex          = (byte)(globalPerceptionsIndex - 1);

            var surprisePerceptions = targetInfo.UsingGlobalPerceptions ?
                                      traits[globalPerceptionsIndex] :
                                      traits[executorIndex];
            float verbProbability    = surprisePerceptions.TotalPerceptions / (float)verbNumTimes;
            float surpriseMultiplier = 0;

            if (verbProbability >= 0.5)
            {
                // surpriseMultiplier is 0
                return(null);
            }

            byte targetIndex = (byte)(globalPerceptionsIndex - 1);

            // assumes that one has complete self-awareness of Timid_Powerful
            var selfEsteem = traits[0];

            // for expressive assertions
            PersonalityTraits expressiveAgreement = traits[targetIndex] - PhysicalExpression;
            var          selfAgreement            = selfEsteem - Traits;
            TraitsVector reactionTraits           = expressiveAgreement.BlendToBounded(expressiveAgreement + selfAgreement, -targetInfo.KnowThemWell);

            var agreement             = (reactionTraits).SumToUBounded();
            var boundedAgreement      = (BoundedNumber)agreement;
            var agreementSignificance = boundedAgreement.Significance();

            if (agreementSignificance.Number * magnitude < VerbSelection.MINIMUM_VERB_SIGNIFICANCE)
            {
                return(null);
            }

            //var agreementInverted = boundedAgreement.UInvert();

            if (verbProbability <= 0.0042) // found by graphing multiplier formula on Desmos
            {
                surpriseMultiplier = 1;
            }
            else
            {
                float bitsOfInformation = (float)Math.Log(verbProbability, 2);
                surpriseMultiplier = ((float)Math.Sqrt(bitsOfInformation) - 1) * 0.55f;
            }

            // how much attention you pay
            var surpriseTraits = (surprisePerceptions - Traits);
            var surprise       = surpriseTraits.SumToUBounded();

            // if you are a good person, and perceive the person to be dishonest, it will change little
            // trust in yourself vs trust in the other person
            // your values are less assertive if you are more timid
            var trust = new BoundedNumber(new UBoundedNumber(selfEsteem.Bad_Good.WeightingFactor - traits[executorIndex].Bad_Good.WeightingFactor));

            // if you trust them more, disagreements are less of a shock
            surprise = agreement.Blend(surprise, trust);
            var scaledAssertions = PhysicalExpression * magnitude;

            if (perception.CircumferentialValues.TryGetValue(targetInfo.EntityID, out PersonalityTraits cValue))
            {
                if (targetInfo.AffectsTarget)
                {
                    cValue.AddVector(scaledAssertions);
                }
                else
                {
                    cValue = cValue + traits[targetIndex];
                }
            }
            else
            {
                if (targetInfo.AffectsTarget)
                {
                    perception.CircumferentialValues.Add(targetInfo.EntityID, scaledAssertions);
                }
                else
                {
                    perception.CircumferentialValues.Add(targetInfo.EntityID, ((TraitsVector)traits[targetIndex] + scaledAssertions));
                }
            }

            var          scaledTraits          = Traits * magnitude;
            TraitsVector oldExecutorPerception = traits[executorIndex];

            traits[executorIndex].Blend(oldExecutorPerception + scaledTraits, traits[globalPerceptionsIndex], true);
            TraitsVector oldTargetPerception = traits[targetIndex];

            var oldTrust = trust;

            // trusting their judgement on this issue
            trust = trust.Blend(
                boundedAgreement,
                selfEsteem.Timid_Powerful
                );

            //agreement = agreement.Suppress(1 - magnitude);
            // Do you react?
            var significance = surprise.Blend(agreementSignificance, selfEsteem.Timid_Powerful.WeightingFactor) * magnitude;

            if (targetInfo.IsYou)
            {
                if (targetInfo.AffectsTarget)
                {
                    significance = new UBoundedNumber(significance.Amplify(0.333f));
                }
                traits[targetIndex].Blend(oldTargetPerception + scaledAssertions, trust, true);
                if (significance.Number < 1 - selfEsteem.Timid_Powerful.WeightingFactor)
                {
                    return(null);
                }
            }
            else
            {
                traits[targetIndex].Blend(
                    oldTargetPerception + scaledAssertions,
                    traits[globalPerceptionsIndex] * trust,
                    true
                    );
                if (!targetInfo.AffectsTarget)
                {
                    significance = significance * 0.667f;
                }
                if (significance.Number < 1 - selfEsteem.Timid_Powerful.WeightingFactor)
                {
                    return(null);
                }
            }

            return(new Reaction(
                       agreement.Suppress(1 - magnitude),
                       surprise,
                       ((PersonalityTraits)reactionTraits).BlendToBounded(surpriseTraits, selfEsteem.Timid_Powerful.WeightingFactor) * magnitude,
                       significance
                       ));
        }
示例#2
0
        public SortedSet <ushort> SelectVerb(ushort entityID, SortedSet <ushort> witnesses)
        {
            var actor = Constants.CHARACTERS[entityID];

            (Emotion bareLeanings, Emotion flags, Emotion actualEmotion) = actor.Emotions.Feelings();
            bool emotional = flags != Emotion.None;
            SortedDictionary <ushort, UBoundedNumber> verbPropensities = emotional ?
                                                                         new SortedDictionary <ushort, UBoundedNumber>(EmotionalVerbs.ToDictionary(k => k, k => new UBoundedNumber())) :
                                                                         new SortedDictionary <ushort, UBoundedNumber>();

            if (emotional)
            {
                foreach (var emotion in VerbsByEmotion)
                {
                    if (flags.HasFlag(emotion.Key))
                    {
                        UBoundedNumber totalEmotions = new UBoundedNumber();
                        if (emotion.Key.HasFlag(Emotion.Euphoric))
                        {
                            totalEmotions += actor.Emotions.Dysphoria_Euphoria;
                        }
                        else if (emotion.Key.HasFlag(Emotion.Dysphoric))
                        {
                            totalEmotions += -actor.Emotions.Dysphoria_Euphoria;
                        }

                        if (emotion.Key.HasFlag(Emotion.Passionate))
                        {
                            totalEmotions += actor.Emotions.Apathy_Passion;
                        }
                        else if (emotion.Key.HasFlag(Emotion.Apathetic))
                        {
                            totalEmotions += -actor.Emotions.Apathy_Passion;
                        }

                        if (emotion.Key.HasFlag(Emotion.Outward))
                        {
                            totalEmotions += actor.Emotions.Inward_Outward;
                        }
                        else if (emotion.Key.HasFlag(Emotion.Inward))
                        {
                            totalEmotions += -actor.Emotions.Inward_Outward;
                        }

                        if (emotion.Key.HasFlag(Emotion.Controlled))
                        {
                            totalEmotions += actor.Emotions.Primitive_Controlled;
                        }
                        else if (emotion.Key.HasFlag(Emotion.Primitive))
                        {
                            totalEmotions += -actor.Emotions.Primitive_Controlled;
                        }

                        foreach (var verb in emotion.Value)
                        {
                            verbPropensities[verb] += totalEmotions;
                        }
                    }
                }
            }

            UBoundedNumber totalEmotionsInverted = UBoundedNumber.FromUnbounded(
                actor.Emotions.Dysphoria_Euphoria.UInvert().UnboundedNumber +
                actor.Emotions.Apathy_Passion.UInvert().UnboundedNumber +
                actor.Emotions.Inward_Outward.UInvert().UnboundedNumber +
                actor.Emotions.Primitive_Controlled.UInvert().UnboundedNumber
                );

            foreach (var verb in EmotionallyNeutralVerbs)
            {
                verbPropensities.Add(verb, totalEmotionsInverted);
            }

            foreach (var verb in CharacterEstablishingVerbs)
            {
                if (verbPropensities.TryGetValue(verb, out UBoundedNumber propensity))
                {
                    verbPropensities[verb] += Constants.VERBS_INFO[verb].PersonalityInclination(actor);
                }
                else
                {
                    verbPropensities.Add(verb, new UBoundedNumber(Constants.VERBS_INFO[verb].PersonalityInclination(actor)));
                }
            }
        }