コード例 #1
0
        public void SetObjectData(ISerializationData dataHolder, ISerializationContext context)
        {
            m_activeIdentities = new Dictionary <Name, Identity>();
            m_kb             = dataHolder.GetValue <KB>("KnowledgeBase");
            this.BodyName    = dataHolder.GetValue <string>("BodyName");
            this.VoiceName   = dataHolder.GetValue <string>("VoiceName");
            m_emotionalState = dataHolder.GetValue <ConcreteEmotionalState>("EmotionalState");
            m_goals          = new Dictionary <string, Goal>();
            var goals = dataHolder.GetValue <Goal[]>("Goals");

            if (goals != null)
            {
                foreach (var g in goals)
                {
                    m_goals.Add(g.Name.ToString(), g);
                }
            }
            m_am          = dataHolder.GetValue <AM>("AutobiographicMemory");
            m_otherAgents = dataHolder.GetValue <Dictionary <Name, AgentEntry> >("OtherAgents");
            if (m_otherAgents == null)
            {
                m_otherAgents = new Dictionary <Name, AgentEntry>();
            }
            BindToRegistry(m_kb);
        }
コード例 #2
0
 public RolePlayCharacterAsset()
 {
     m_activeIdentities = new Dictionary <Name, Identity>();
     m_kb             = new KB(RPCConsts.DEFAULT_CHARACTER_NAME);
     m_am             = new AM();
     m_emotionalState = new ConcreteEmotionalState();
     m_goals          = new Dictionary <string, Goal>();
     m_otherAgents    = new Dictionary <Name, AgentEntry>();
     BindToRegistry(m_kb);
 }
コード例 #3
0
 public RolePlayCharacterAsset()
 {
     m_log = new List <LogEntry>();
     m_activeIdentities = new Dictionary <Name, Identity>();
     m_kb             = new KB(RPCConsts.DEFAULT_CHARACTER_NAME);
     m_am             = new AM();
     m_emotionalState = new ConcreteEmotionalState();
     m_allowAuthoring = true;
     m_otherAgents    = new Dictionary <Name, AgentEntry>();
     BindToRegistry(m_kb);
 }
コード例 #4
0
        //This is a small console program to exemplify the main functionality of the Emotional Appraisal Asset
        static void Main(string[] args)
        {
            var kickEvent = Name.BuildName("Event(Action-End, John, *, *)");

            EmotionalAppraisalAsset ea = EmotionalAppraisalAsset.LoadFromFile("../../../Examples/EA-Tutorial/EATest.ea");



            //The following lines add an appraisal rule that will make the kickEvent be perceived as undesirable
            //Normally, these rules should be authored using the AuthoringTool provided with the asset but they can also be added dynamically

            /*   var rule = new AppraisalRuleDTO {EventMatchingTemplate = (Name)"Event(Action-End, [s], *, *)", Desirability = (Name)"4"};
             * ea.AddOrUpdateAppraisalRule(rule);
             */

            var am = new AM();
            var kb = new KB((Name)"John");

            kb.Tell(Name.BuildName("Likes(Mary)"), Name.BuildName("John"), Name.BuildName("SELF"));

            var emotionalState = new ConcreteEmotionalState();

            //Emotions are generated by the appraisal of the events that occur in the game world
            ea.AppraiseEvents(new[] { kickEvent }, emotionalState, am, kb);

            Console.WriteLine("\nMood on tick '" + am.Tick + "': " + emotionalState.Mood);
            Console.WriteLine("Active Emotions: " + string.Concat(emotionalState.GetAllEmotions().Select(e => e.EmotionType + "-" + e.Intensity + " ")));

            //Each event that is appraised will be stored in the autobiographical memory that was passed as a parameter
            Console.WriteLine("\nEvents occured so far: " + string.Concat(am.RecallAllEvents().Select(e => "\nId: " + e.Id + " Event: " + e.EventName.ToString())));

            //The update function will increase the current tick by 1. Each active emotion will decay to 0 and the mood will slowly return to 0
            for (int i = 0; i < 3; i++)
            {
                am.Tick++;
                emotionalState.Decay(am.Tick);
                Console.WriteLine("\nMood on tick '" + am.Tick + "': " + emotionalState.Mood);
                Console.WriteLine("Active Emotions: " + string.Concat(emotionalState.GetAllEmotions().Select(e => e.EmotionType + "-" + e.Intensity + " ")));
            }

            //The asset can also be loaded from an existing file using the following method:
            ea = EmotionalAppraisalAsset.LoadFromFile("../../../Examples/EA-Tutorial/EATest.ea");

            Console.ReadKey();
        }
コード例 #5
0
        public void SetObjectData(ISerializationData dataHolder, ISerializationContext context)
        {
            m_allowAuthoring   = true;
            m_log              = new List <LogEntry>();
            m_activeIdentities = new Dictionary <Name, Identity>();
            m_kb           = dataHolder.GetValue <KB>("KnowledgeBase");
            this.BodyName  = dataHolder.GetValue <string>("BodyName");
            this.VoiceName = dataHolder.GetValue <string>("VoiceName");
            this.m_emotionalAppraisalAssetSource      = dataHolder.GetValue <string>("EmotionalAppraisalAssetSource");
            this.m_emotionalDecisionMakingAssetSource = dataHolder.GetValue <string>("EmotionalDecisionMakingSource");
            this.m_socialImportanceAssetSource        = dataHolder.GetValue <string>("SocialImportanceAssetSource");
            this.m_commeillFautAssetSource            = dataHolder.GetValue <string>("CommeillFautAssetSource");
            m_emotionalState = dataHolder.GetValue <ConcreteEmotionalState>("EmotionalState");
            m_am             = dataHolder.GetValue <AM>("AutobiographicMemory");
            m_otherAgents    = dataHolder.GetValue <Dictionary <Name, AgentEntry> >("OtherAgents");
            if (m_otherAgents == null)
            {
                m_otherAgents = new Dictionary <Name, AgentEntry>();
            }


            BindToRegistry(m_kb);
        }
コード例 #6
0
 public AgentEntry(Name id)
 {
     Name           = id;
     EmotionalState = new ConcreteEmotionalState();
 }