Exemple #1
0
        private IEnumerable <DynamicPropertyResult> GetEmotionsForEntity(IEmotionalState state,
                                                                         Name emotionName, IQueryable kb, Name perspective, IEnumerable <SubstitutionSet> constraints)
        {
            if (emotionName.IsVariable)
            {
                foreach (var emotion in state.GetAllEmotions())
                {
                    var sub = new Substitution(emotionName, new ComplexValue((Name)emotion.EmotionType));
                    foreach (var c in constraints)
                    {
                        if (c.Conflicts(sub))
                        {
                            continue;
                        }

                        var newConstraints = new SubstitutionSet(c);
                        newConstraints.AddSubstitution(sub);
                        yield return(new DynamicPropertyResult(new ComplexValue(Name.BuildName(emotion.Intensity)), newConstraints));
                    }
                }
            }
            else
            {
                foreach (var resultPair in kb.AskPossibleProperties(emotionName, perspective, constraints))
                {
                    string emotionKey = resultPair.Item1.Value.ToString();
                    var    emotion    = state.GetEmotionsByType(emotionKey).OrderByDescending(e => e.Intensity).FirstOrDefault();
                    float  value      = emotion?.Intensity ?? 0;
                    foreach (var c in resultPair.Item2)
                    {
                        yield return(new DynamicPropertyResult(new ComplexValue(Name.BuildName(value)), c));
                    }
                }
            }
        }
Exemple #2
0
            protected override IEnumerable <SubstitutionSet> CheckActivation(IQueryable db, Name perspective, IEnumerable <SubstitutionSet> constraints)
            {
                Name realValue = db.AskPossibleProperties(m_value, perspective, null).First().Item1.Value;

                foreach (var pair in m_retriver.Retrieve(db, perspective, constraints))
                {
                    if (CompareValues(pair.Item1.Value, realValue, m_operation))
                    {
                        yield return(pair.Item2);
                    }
                }
            }