Пример #1
0
        public void Test_RPC_Decide()
        {
            var kb = new KB((Name)"Matt");

            var rpc = BuildEmotionalRPCAsset();

            var edm = new EmotionalDecisionMakingAsset();

            edm.AddActionRule(new ActionLibrary.DTOs.ActionRuleDTO()
            {
                Action = (Name)"EnterRoom", Priority = Name.BuildName(3), Target = (Name)"[x]", Conditions = new Conditions.DTOs.ConditionSetDTO()
                {
                    ConditionSet = new string[] { "[x]!=SELF" }
                }
            });

            rpc.m_emotionalDecisionMakingAsset = edm;

            edm.RegisterKnowledgeBase(rpc.m_kb);

            PopulateEventSet(1);

            foreach (var eve in eventSets[1])
            {
                rpc.Perceive((Name)eve);
                rpc.Update();
            }

            var actions = rpc.Decide();

            Assert.IsNotNull(actions);
        }
Пример #2
0
        /// <summary>
        /// Loads the associated assets from the defined sources and prevents further authoring of the asset
        /// </summary>
        public void LoadAssociatedAssets()
        {
            var charName = CharacterName.ToString();

            EmotionalAppraisalAsset ea = Loader(m_emotionalAppraisalAssetSource, () => new EmotionalAppraisalAsset());

            EmotionalDecisionMakingAsset edm = Loader(m_emotionalDecisionMakingAssetSource, () => new EmotionalDecisionMakingAsset());
            SocialImportanceAsset        si  = Loader(m_socialImportanceAssetSource, () => new SocialImportanceAsset());
            CommeillFautAsset            cfa = Loader(m_commeillFautAssetSource, () => new CommeillFautAsset());

            m_emotionalAppraisalAsset      = ea;
            m_emotionalDecisionMakingAsset = edm;
            m_socialImportanceAsset        = si;
            m_commeillFautAsset            = cfa;

            MCTSAsset mcts = new MCTSAsset();

            //Dynamic properties
            BindToRegistry(m_kb);
            edm.RegisterKnowledgeBase(m_kb);
            si.RegisterKnowledgeBase(m_kb);
            cfa.RegisterKnowledgeBase(m_kb);
            mcts.RegisterKnowledgeBase(m_kb);
            m_allowAuthoring = false;
        }
Пример #3
0
        //This is a small console program to exemplify the main functionality of the Emotional Decision Making Asset
        static void Main(string[] args)
        {
            //First we construct a new instance of the EmotionalDecisionMakingAsset class
            var edm = new EmotionalDecisionMakingAsset();

            //Then, we have to register an existing knowledge base to the asset so it can check for
            //beliefs are true
            var kb = new KB((Name)"John");

            kb.Tell((Name)"LikesToFight(SELF)", (Name)"True");
            edm.RegisterKnowledgeBase(kb);

            //create an action rule
            var actionRule = new ActionRuleDTO {
                Action = Name.BuildName("Kick"), Priority = Name.BuildName("4"), Target = (Name)"Player"
            };

            //add the reaction rule
            var id = edm.AddActionRule(actionRule);

            edm.AddRuleCondition(id, "LikesToFight(SELF) = True");
            var actions = edm.Decide(Name.UNIVERSAL_SYMBOL);

            Console.WriteLine("Decisions: ");
            foreach (var a in actions)
            {
                Console.WriteLine(a.Name.ToString() + " p: " + a.Utility);
            }

            //this is how you can load the asset from a file
            Console.WriteLine("Loading From File: ");
            edm = EmotionalDecisionMakingAsset.LoadFromFile("../../../Examples/EDM-Tutorial/EDMTest.edm");
            edm.RegisterKnowledgeBase(kb);
            actions = edm.Decide(Name.UNIVERSAL_SYMBOL);

            foreach (var a in actions)
            {
                Console.WriteLine(a.Name.ToString() + " p: " + a.Utility);
            }
            Console.WriteLine("Decisions: ");
            foreach (var a in actions)
            {
                Console.WriteLine(a.Name.ToString() + " p: " + a.Utility);
            }
            Console.ReadKey();
        }