Exemple #1
0
    private bool EstimateBindingsQuality(ActionInstance instance, WorldModel context)//calculate expected affinity from the instance, as well as expected utility, recursion would happen here to evaluate future actions
    {
        var OpenCandidateList = new List <CharModel>(context.Characters.Values);

        for (int i = 0; i < OpenCandidateList.Count;)
        {
            if (instance.InvolvedCharacters.ContainsValue(OpenCandidateList[i].Character))
            {
                OpenCandidateList.RemoveAt(i);
            }
            else
            {
                i++;
            }
        }
        instance.RunCharacterControlledPreferenceRules();
        var possibleBindingsinstances = RecursiveBindings(instance, OpenCandidateList, instance.Template.EngineControlledRoles);

        SetBindingsProbability(possibleBindingsinstances);

        instance.Affinity = EvaluateBindingsAffinity(possibleBindingsinstances);
        if (instance.Affinity < Electrum.affinityTreshold)
        {
            return(false);                                              //the action will be discarded, as it is too unattractive
        }
        //utility estimation
        instance.ExpectedImmediateUtility = EvaluateBindingsUtility(context, possibleBindingsinstances);
        return(true);
    }