private static double CalculateAccuracy(IDecisionNode root, List <Episode> episodes)
        {
            double correctWeight = episodes.AsParallel().Sum(ep => root.Evaluate(ep.World, ep.Hero) == ep.Tactic ? ep.Weight : 0.0);
            double totalWeight   = episodes.Sum(ep => ep.Weight);

            return(correctWeight / totalWeight);
        }
        /// <summary>
        /// Main method - template for the FileController evaluation
        /// </summary>
        /// <param name="traits">Character Traits</param>
        /// <param name="memory">Character's Memory and knowledge</param>
        /// <param name="perceivedEvent">Event to evaluate</param>
        /// <returns>Character's reaction</returns>
        public List <Reaction> Evaluate(CharacterTraits traits, Memory.Memory memory, PerceivedEvent perceivedEvent)
        {
            List <Reaction> reactions;

            if (EvaluateNode(perceivedEvent, memory, traits))
            {
                if (RightNode == null)
                {
                    throw new NullNodeException($"Right node for node {this} is missing.");
                }

                reactions = RightNode.Evaluate(traits, memory, perceivedEvent);

                if (RightNode.GetNodeType() == "Node")
                {
                    DataToMemorize.AddRange(((AbstractDecisionNode)RightNode).DataToMemorize);
                }
            }
            else
            {
                if (LeftNode == null)
                {
                    throw new NullNodeException($"Left node for node {this} is missing.");
                }

                reactions = LeftNode.Evaluate(traits, memory, perceivedEvent);

                if (LeftNode.GetNodeType() == "Node")
                {
                    DataToMemorize.AddRange(((AbstractDecisionNode)LeftNode).DataToMemorize);
                }
            }

            return(reactions);
        }
Beispiel #3
0
        public List <Reaction> Evaluate(Character character, Action action, IDecisionNode decisionTreeRootNode)
        {
            var reaction = decisionTreeRootNode.Evaluate(character.MyTraits, character.MyMemory, action);

            character.MyMemory.AddNodeTestResults(((AbstractDecisionNode)decisionTreeRootNode).GetNodeTestsData());

            reaction[0].ReactionScore = ((AbstractDecisionNode)decisionTreeRootNode).GetNodeTestsData().Sum(info => info.ProfileScore);

            character.MyMemory.AddRecentReactions(reaction);

            return(reaction);
        }
Beispiel #4
0
 public bool Evaluate(Person person)
 {
     return(_startLoanNode.Evaluate(person));
 }