private EmotionalDecisionMakingAsset BuildTestAsset()
        {
            var asset = new EmotionalDecisionMakingAsset();

            asset.AddActionRule(new ActionRuleDTO()
            {
                Action = Name.BuildName("Speak([speachType])"), Target = Name.BuildName("[x]")
            });
            asset.AddActionRule(new ActionRuleDTO()
            {
                Action = Name.BuildName("Speak(formal)"), Target = Name.BuildName("[x]")
            });
            return(asset);
        }
        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);
        }
Exemple #3
0
        private void addOrEditButton_Click(object sender, EventArgs e)
        {
            try
            {
                var newReaction = new ActionRuleDTO
                {
                    Action   = textBoxAction.Value,
                    Target   = textBoxTarget.Value,
                    Priority = textBoxPriority.Value,
                    Layer    = textBoxLayer.Value,
                };

                if (_reactionToEdit != null)
                {
                    _edmAsset.UpdateActionRule(_reactionToEdit, newReaction);
                }
                else
                {
                    _edmAsset.AddActionRule(newReaction);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Resources.ErrorDialogTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            this.Close();
        }
Exemple #4
0
 private void buttonDuplicateReaction_Click(object sender, EventArgs e)
 {
     if (dataGridViewReactiveActions.SelectedRows.Count == 1)
     {
         var a = ((ObjectView <ActionRuleDTO>)dataGridViewReactiveActions.SelectedRows[0].DataBoundItem).Object;
         var duplicateAction = CloneHelper.Clone(a);
         _loadedAsset.AddActionRule(duplicateAction);
         actionRules.DataSource = _loadedAsset.GetAllActionRules().ToList();
         actionRules.Refresh();
     }
 }
Exemple #5
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();
        }