//This is a small console program to exemplify the main functionality of the Emotional Appraisal Asset static void Main(string[] args) { AssetManager.Instance.Bridge = new BasicIOBridge(); var kickEvent = "Event(Action-Start, Player, Kick, John)"; // To create a new asset it is required to tell the name of the agent which will correpond to the perspective of the "SELF" EmotionalAppraisalAsset ea = new EmotionalAppraisalAsset("John"); //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 = "Event(Action-Start, *, Kick, SELF)", Desirability = -5f, Praiseworthiness = -3f }; ea.AddOrUpdateAppraisalRule(rule); //Emotions are generated by the appraisal of the events that occur in the game world ea.AppraiseEvents(new[] { kickEvent }); Console.WriteLine("\nAfter appraising '" + kickEvent + "'\nWith the appraisal rule '" + rule.EventMatchingTemplate + " Desirability: "+rule.Desirability+ " Praiseworthiness: " + rule.Praiseworthiness + "'"); Console.WriteLine("\nMood on tick '" + ea.Tick + "': " + ea.Mood); Console.WriteLine("Active Emotions: " + string.Concat(ea.ActiveEmotions.Select(e => e.Type + "-" + e.Intensity + " "))); //Each event that is appraised will be stored an the agent's autobiographical memory Console.WriteLine("\nEvents occured so far: " + string.Concat(ea.EventRecords.Select(e => "\nId: " + e.Id + " Event: " + e.Event))); //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++) { ea.Update(); Console.WriteLine("\nMood on tick '" + ea.Tick + "': " + ea.Mood); Console.WriteLine("Active Emotions: " + string.Concat(ea.GetAllActiveEmotions().Select(e => e.EmotionType + "-" + e.Intensity + " "))); } //The asset can also be loaded from an existing file using the following method: ea = EmotionalAppraisalAsset.LoadFromFile("../../../Examples/EATest.ea"); Console.ReadKey(); }
public void ChangeCurrentRule(AppraisalRuleDTO rule) { if (rule != null) { this.SelectedRuleId = rule.Id; CurrentRuleConditions.SetData(_emotionalAppraisalAsset.GetAllAppraisalRuleConditions(SelectedRuleId)); } }
public AppraisalRule(AppraisalRuleDTO appraisalRuleDTO) { m_id = (appraisalRuleDTO.Id == Guid.Empty)?Guid.NewGuid() : appraisalRuleDTO.Id; EventName = Name.BuildName(appraisalRuleDTO.EventMatchingTemplate); Desirability = appraisalRuleDTO.Desirability; Praiseworthiness = appraisalRuleDTO.Praiseworthiness; Conditions = appraisalRuleDTO.Conditions==null ? new ConditionSet() : new ConditionSet(appraisalRuleDTO.Conditions); }
/// <summary> /// Adds an emotional reaction to an event /// </summary> /// <param name="emotionalAppraisalRule">the AppraisalRule to add</param> public void AddOrUpdateAppraisalRule(AppraisalRuleDTO emotionalAppraisalRuleDTO) { AppraisalRule existingRule = GetAppraisalRule(emotionalAppraisalRuleDTO.Id); if (existingRule != null) { RemoveAppraisalRule(existingRule); existingRule.Desirability = emotionalAppraisalRuleDTO.Desirability; existingRule.Praiseworthiness = emotionalAppraisalRuleDTO.Praiseworthiness; existingRule.EventName = Name.BuildName(emotionalAppraisalRuleDTO.EventMatchingTemplate); existingRule.Conditions = new ConditionSet(emotionalAppraisalRuleDTO.Conditions); } else { existingRule = new AppraisalRule(emotionalAppraisalRuleDTO); } AddEmotionalReaction(existingRule); }
private static RolePlayCharacterAsset BuildEmotionalRPCAsset(int eaSet = -1) { var kb = new KB((Name)"Matt"); var ea = new EmotionalAppraisalAsset(); if (eaSet == -1) { var appraisalRule = new EmotionalAppraisal.DTOs.AppraisalRuleDTO() { Conditions = new Conditions.DTOs.ConditionSetDTO(), EventMatchingTemplate = (Name)"Event(*, *,*, *)", AppraisalVariables = new AppraisalVariables(new List <AppraisalVariableDTO>() { new AppraisalVariableDTO() { Name = OCCAppraisalVariables.DESIRABILITY, Value = (Name)"2" }, new AppraisalVariableDTO() { Name = OCCAppraisalVariables.PRAISEWORTHINESS, Value = (Name)"2" } }) }; ea.AddOrUpdateAppraisalRule(appraisalRule); } else { PopulateAppraisalRuleSet(); ea.AddOrUpdateAppraisalRule(appraisalRuleSet[eaSet]); } ea.AddOrUpdateGoal(new GoalDTO() { Name = "Goal", Significance = 5, Likelihood = 0.5f }); ea.AddOrUpdateGoal(new GoalDTO() { Name = "GoalNegative", Significance = 5, Likelihood = 0.2f }); ea.AddOrUpdateGoal(new GoalDTO() { Name = "GoalPositive", Significance = 5, Likelihood = 0.8f }); var rpc = new RolePlayCharacterAsset { BodyName = "Male", VoiceName = "Male", CharacterName = (Name)"Matt", m_kb = kb, }; rpc.m_emotionalAppraisalAsset = ea; rpc.BindToRegistry(rpc.m_kb); EmotionalDecisionMakingAsset edm = new EmotionalDecisionMakingAsset(); SocialImportanceAsset si = new SocialImportanceAsset(); CommeillFautAsset cfa = new CommeillFautAsset(); rpc.m_emotionalAppraisalAsset = ea; rpc.m_emotionalDecisionMakingAsset = edm; rpc.m_socialImportanceAsset = si; rpc.m_commeillFautAsset = cfa; return(rpc); }
public void AddOrUpdateAppraisalRule(AppraisalRuleDTO newRule) { _emotionalAppraisalAsset.AddOrUpdateAppraisalRule(newRule); RefreshData(); _mainForm.SetModified(); }