public void InverseAppraisal(EmotionalAppraisalAsset emotionalModule, IAppraisalFrame frame) { float desirability = frame.GetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY); float praiseworthiness = frame.GetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS); if (desirability != 0 || praiseworthiness != 0) { var eventName = frame.AppraisedEvent.EventName.ApplyPerspective(emotionalModule.Perspective); AppraisalRule r = new AppraisalRule(eventName, null); r.Desirability = desirability; r.Praiseworthiness = praiseworthiness; //r.EventObject = frame.AppraisedEvent.ToIdentifierName().RemovePerspective(emotionalModule.Perspective); AddEmotionalReaction(r); } }
/* if(hopeEmotion != null) { * if(fearEmotion != null && fearEmotion.Intensity > hopeEmotion.Intensity) { * potential = fearEmotion.Potential; * finalEmotion = fearfullOutcome; * } * else { * potential = hopeEmotion.Potential; * finalEmotion = hopefullOutcome; * } * } * else if(fearEmotion != null) { * potential = fearEmotion.Potential; * finalEmotion = fearfullOutcome; * } * * //The goal importance now affects 66% of the final potential value for the emotion * potential = (potential + 2* goalImportance) / 3; * * return new OCCBaseEmotion(finalEmotion, potential, evtId, eventName); * }*/ /* * private static OCCBaseEmotion AppraiseGoalEnd(OCCEmotionType hopefullOutcome, OCCEmotionType fearfullOutcome, IActiveEmotion hopeEmotion, IActiveEmotion fearEmotion, float goalImportance, uint evtId, Name eventName) { * * OCCEmotionType finalEmotion; * float potential = goalImportance; * finalEmotion = hopefullOutcome; * * if(hopeEmotion != null) { * if(fearEmotion != null && fearEmotion.Intensity > hopeEmotion.Intensity) { * potential = fearEmotion.Potential; * finalEmotion = fearfullOutcome; * } * else { * potential = hopeEmotion.Potential; * finalEmotion = hopefullOutcome; * } * } * else if(fearEmotion != null) { * potential = fearEmotion.Potential; * finalEmotion = fearfullOutcome; * } * * //The goal importance now affects 66% of the final potential value for the emotion * potential = (potential + 2* goalImportance) / 3; * * return new OCCBaseEmotion(finalEmotion, potential, evtId, eventName); * } * * */ ///// <summary> ///// Appraises a Goal's success according to the emotions that the agent is experiencing ///// </summary> ///// <param name="hopeEmotion">the emotion of Hope for achieving the goal that the character feels</param> ///// <param name="fearEmotion">the emotion of Fear for not achieving the goal that the character feels</param> ///// <param name="goalImportance">how important is the goal to the agent</param> ///// <param name="evt">The event that triggered the emotion</param> ///// <returns>the emotion created</returns> //private static OCCBaseEmotion AppraiseGoalSuccess(IActiveEmotion hopeEmotion, IActiveEmotion fearEmotion, float goalImportance, uint evt) { // return AppraiseGoalEnd(OCCEmotionType.Satisfaction,OCCEmotionType.Relief,hopeEmotion,fearEmotion,goalImportance,evt); //} ///// <summary> ///// Appraises a Goal's Failure according to the emotions that the agent is experiencing ///// </summary> ///// <param name="hopeEmotion">the emotion of Hope for achieving the goal that the character feels</param> ///// <param name="fearEmotion">the emotion of Fear for not achieving the goal that the character feels</param> ///// <param name="goalImportance">how important is the goal to the agent</param> ///// <param name="evt">The event that triggered the emotion</param> ///// <returns></returns> //public static OCCBaseEmotion AppraiseGoalFailure(IActiveEmotion hopeEmotion, IActiveEmotion fearEmotion, float goalImportance, uint evt) { // return AppraiseGoalEnd(OCCEmotionType.Disappointment,OCCEmotionType.FearsConfirmed,hopeEmotion,fearEmotion,goalImportance,evt); //} ///// <summary> ///// Appraises a Goal's likelihood of succeeding ///// </summary> ///// <param name="e">The event that triggered the emotion</param> ///// <param name="goalConduciveness">???????</param> ///// <param name="prob">probability of sucess</param> ///// <returns></returns> // public static OCCBaseEmotion AppraiseGoalSuccessProbability(uint evt, float goalConduciveness, float prob) { // return new OCCBaseEmotion(OCCEmotionType.Hope, prob * goalConduciveness, evt); // } ///// <summary> ///// Appraises a Goal's likelihood of failure ///// </summary> ///// <param name="e">The event that triggered the emotion</param> ///// <param name="goalConduciveness">???????</param> ///// <param name="prob">probability of failure</param> ///// <returns></returns> //public static OCCBaseEmotion AppraiseGoalFailureProbability(uint evt, float goalConduciveness, float prob) //{ // return new OCCBaseEmotion(OCCEmotionType.Fear, prob * goalConduciveness, evt); //} public IEnumerable <IEmotion> AffectDerivation(EmotionalAppraisalAsset emotionalModule, IAppraisalFrame frame) { var evt = frame.AppraisedEvent; if (frame.ContainsAppraisalVariable(OCCAppraisalVariables.DESIRABILITY) && frame.ContainsAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS)) { float desirability = frame.GetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY); float praiseworthiness = frame.GetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS); var composedEmotion = OCCAppraiseCompoundEmotions(evt, desirability, praiseworthiness); if (composedEmotion != null) { yield return(composedEmotion); } } if (frame.ContainsAppraisalVariable(OCCAppraisalVariables.DESIRABILITY)) { float desirability = frame.GetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY); if (desirability != 0) { // yield return OCCAppraiseWellBeing(evt.Id, evt.EventName, desirability * 0.5f); int counter = 0; foreach (string variable in frame.AppraisalVariables.Where(v => v.StartsWith(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER))) { counter++; string other = variable.Substring(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER.Length); float desirabilityForOther = frame.GetAppraisalVariable(variable); if (desirabilityForOther != 0) { yield return(OCCAppraiseFortuneOfOthers(evt, desirability, desirabilityForOther, other)); } } if (counter == 0) { yield return(OCCAppraiseWellBeing(evt.Id, evt.EventName, desirability)); } } } foreach (string variable in frame.AppraisalVariables.Where(v => v.StartsWith(OCCAppraisalVariables.PRAISEWORTHINESS))) { float praiseworthiness = frame.GetAppraisalVariable(variable); string other = variable.Substring(OCCAppraisalVariables.PRAISEWORTHINESS.Length); if (other == null || other == " ") { yield return(OCCAppraisePraiseworthiness(evt, praiseworthiness, "SELF")); } else { yield return(OCCAppraisePraiseworthiness(evt, praiseworthiness, other)); } } /*if(frame.ContainsAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS)) * { * float praiseworthiness = frame.GetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS); * if (praiseworthiness != 0) * yield return OCCAppraisePraiseworthiness(evt, praiseworthiness, frame.Perspective); * }*/ if (frame.ContainsAppraisalVariable(OCCAppraisalVariables.LIKE)) { float like = frame.GetAppraisalVariable(OCCAppraisalVariables.LIKE); if (like != 0) { yield return(OCCAppraiseAttribution(evt, like)); } } foreach (string variable in frame.AppraisalVariables.Where(v => v.StartsWith(OCCAppraisalVariables.GOALSUCCESSPROBABILITY))) { float goalSuccessProbability = frame.GetAppraisalVariable(variable); string goalName = variable.Substring(OCCAppraisalVariables.GOALSUCCESSPROBABILITY.Length + 1); var goals = emotionalModule.GetAllGoals().ToList(); GoalDTO g = goals.Find(x => goalName.ToString() == x.Name.ToString()); if (g == null) { continue; } var previousValue = g.Likelihood; g.Likelihood = goalSuccessProbability; yield return(AppraiseGoalSuccessProbability(evt, goalSuccessProbability, previousValue, g.Significance)); } }
public void InverseAppraisal(EmotionalAppraisalAsset emotionalModule, IAppraisalFrame frame) { float desirability = frame.GetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY); float praiseworthiness = frame.GetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS); if (desirability != 0 || praiseworthiness != 0) { var eventName = frame.AppraisedEvent.EventName.ApplyPerspective((Name)emotionalModule.Perspective); AppraisalRule r = new AppraisalRule(eventName,null); r.Desirability = desirability; r.Praiseworthiness = praiseworthiness; //r.EventObject = frame.AppraisedEvent.ToIdentifierName().RemovePerspective(emotionalModule.Perspective); AddEmotionalReaction(r); } }
public IEnumerable <IEmotion> AffectDerivation(EmotionalAppraisalAsset emotionalModule, Dictionary <string, Goal> goals, IAppraisalFrame frame) { var evt = frame.AppraisedEvent; bool returnedEmotion = false; if (frame.ContainsAppraisalVariable(OCCAppraisalVariables.DESIRABILITY)) { float desirability = frame.GetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY); foreach (string variable in frame.AppraisalVariables.Where(v => v.StartsWith(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER))) { string other = variable.Substring(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER.Length); float desirabilityForOther = frame.GetAppraisalVariable(variable); if (desirabilityForOther != 0) { returnedEmotion = true; yield return(OCCAppraiseFortuneOfOthers(evt, desirability, desirabilityForOther, other)); } } if (frame.ContainsAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS) && !returnedEmotion) { float praiseworthiness = frame.GetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS); var composedEmotion = OCCAppraiseCompoundEmotions(evt, desirability, praiseworthiness); if (composedEmotion != null) { returnedEmotion = true; yield return(composedEmotion); } } } if (!returnedEmotion) { foreach (string variable in frame.AppraisalVariables.Where(v => v.StartsWith(OCCAppraisalVariables.PRAISEWORTHINESS))) { float praiseworthiness = frame.GetAppraisalVariable(variable); string other = variable.Substring(OCCAppraisalVariables.PRAISEWORTHINESS.Length); if (other == null || other == " ") { yield return(OCCAppraisePraiseworthiness(evt, praiseworthiness, "SELF")); } else { yield return(OCCAppraisePraiseworthiness(evt, praiseworthiness, other)); } } } if (frame.ContainsAppraisalVariable(OCCAppraisalVariables.LIKE)) { float like = frame.GetAppraisalVariable(OCCAppraisalVariables.LIKE); if (like != 0) { yield return(OCCAppraiseAttribution(evt, like)); } } if (frame.ContainsAppraisalVariable(OCCAppraisalVariables.DESIRABILITY) && !returnedEmotion) { float desirability = frame.GetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY); yield return(OCCAppraiseWellBeing(evt.Id, evt.EventName, desirability)); } foreach (string variable in frame.AppraisalVariables.Where(v => v.StartsWith(OCCAppraisalVariables.GOALSUCCESSPROBABILITY))) { float goalSuccessProbability = frame.GetAppraisalVariable(variable); string goalName = variable.Substring(OCCAppraisalVariables.GOALSUCCESSPROBABILITY.Length + 1); if (goals == null) { continue; } Goal g = goals[goalName]; if (g == null) { continue; } var previousValue = g.Likelihood; g.Likelihood = goalSuccessProbability; yield return(AppraiseGoalSuccessProbability(evt, goalSuccessProbability, previousValue, g.Significance)); } }
///// <summary> ///// Appraises a Goal's success according to the emotions that the agent is experiencing ///// </summary> ///// <param name="hopeEmotion">the emotion of Hope for achieving the goal that the character feels</param> ///// <param name="fearEmotion">the emotion of Fear for not achieving the goal that the character feels</param> ///// <param name="goalImportance">how important is the goal to the agent</param> ///// <param name="evt">The event that triggered the emotion</param> ///// <returns>the emotion created</returns> //private static OCCBaseEmotion AppraiseGoalSuccess(IActiveEmotion hopeEmotion, IActiveEmotion fearEmotion, float goalImportance, uint evt) { // return AppraiseGoalEnd(OCCEmotionType.Satisfaction,OCCEmotionType.Relief,hopeEmotion,fearEmotion,goalImportance,evt); //} ///// <summary> ///// Appraises a Goal's Failure according to the emotions that the agent is experiencing ///// </summary> ///// <param name="hopeEmotion">the emotion of Hope for achieving the goal that the character feels</param> ///// <param name="fearEmotion">the emotion of Fear for not achieving the goal that the character feels</param> ///// <param name="goalImportance">how important is the goal to the agent</param> ///// <param name="evt">The event that triggered the emotion</param> ///// <returns></returns> //public static OCCBaseEmotion AppraiseGoalFailure(IActiveEmotion hopeEmotion, IActiveEmotion fearEmotion, float goalImportance, uint evt) { // return AppraiseGoalEnd(OCCEmotionType.Disappointment,OCCEmotionType.FearsConfirmed,hopeEmotion,fearEmotion,goalImportance,evt); //} ///// <summary> ///// Appraises a Goal's likelihood of succeeding ///// </summary> ///// <param name="e">The event that triggered the emotion</param> ///// <param name="goalConduciveness">???????</param> ///// <param name="prob">probability of sucess</param> ///// <returns></returns> //public static OCCBaseEmotion AppraiseGoalSuccessProbability(uint evt, float goalConduciveness, float prob) { // return new OCCBaseEmotion(OCCEmotionType.Hope, prob * goalConduciveness, evt); //} ///// <summary> ///// Appraises a Goal's likelihood of failure ///// </summary> ///// <param name="e">The event that triggered the emotion</param> ///// <param name="goalConduciveness">???????</param> ///// <param name="prob">probability of failure</param> ///// <returns></returns> //public static OCCBaseEmotion AppraiseGoalFailureProbability(uint evt, float goalConduciveness, float prob) //{ // return new OCCBaseEmotion(OCCEmotionType.Fear, prob * goalConduciveness, evt); //} public IEnumerable <IEmotion> AffectDerivation(EmotionalAppraisalAsset emotionalModule, IAppraisalFrame frame) { var evt = frame.AppraisedEvent; if (frame.ContainsAppraisalVariable(OCCAppraisalVariables.DESIRABILITY) && frame.ContainsAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS)) { float desirability = frame.GetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY); float praiseworthiness = frame.GetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS); var composedEmotion = OCCAppraiseCompoundEmotions(evt, desirability, praiseworthiness); if (composedEmotion != null) { yield return(composedEmotion); } } if (frame.ContainsAppraisalVariable(OCCAppraisalVariables.DESIRABILITY)) { float desirability = frame.GetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY); if (desirability != 0) { yield return(OCCAppraiseWellBeing(evt.Id, evt.EventName, desirability)); //foreach(string variable in frame.AppraisalVariables.Where(v => v.StartsWith(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER))) //{ // string other = variable.Substring(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER.Length); // float desirabilityForOther = frame.GetAppraisalVariable(variable); // if (desirabilityForOther != 0) // yield return OCCAppraiseFortuneOfOthers(evt.Id, desirability, desirabilityForOther, other); //} } } if (frame.ContainsAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS)) { float praiseworthiness = frame.GetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS); if (praiseworthiness != 0) { yield return(OCCAppraisePraiseworthiness(evt, praiseworthiness, frame.Perspective)); } } //if(frame.ContainsAppraisalVariable(OCCAppraisalVariables.LIKE)) //{ // float like = frame.GetAppraisalVariable(OCCAppraisalVariables.LIKE); // if (like != 0) // yield return OCCAppraiseAttribution(evt, like); //} //if(frame.ContainsAppraisalVariable(OCCAppraisalVariables.GOALCONDUCIVENESS)) //{ // float goalConduciveness = frame.GetAppraisalVariable(OCCAppraisalVariables.GOALCONDUCIVENESS); // if(goalConduciveness!=0) // { // var status = frame.GetAppraisalVariable(OCCAppraisalVariables.GOALSTATUS); // if(status == GOALUNCONFIRMED) // { // float prob = frame.GetAppraisalVariable(OCCAppraisalVariables.SUCCESSPROBABILITY); // if (prob != 0) // yield return AppraiseGoalSuccessProbability(evt.Id, goalConduciveness, prob); // prob = frame.GetAppraisalVariable(OCCAppraisalVariables.FAILUREPROBABILITY); // if (prob != 0) // yield return AppraiseGoalFailureProbability(evt.Id, goalConduciveness, prob); // } // else // { // //TODO find a better way to retrive the active emotions, without allocating extra KB // var fear = emotionalModule.EmotionalState.GetEmotion(new OCCBaseEmotion(OCCEmotionType.Fear, 0, evt.Id)); // var hope = emotionalModule.EmotionalState.GetEmotion(new OCCBaseEmotion(OCCEmotionType.Hope, 0, evt.Id)); // if (status == GOALCONFIRMED) // yield return AppraiseGoalSuccess(hope, fear, goalConduciveness, evt.Id); // else if (status == GOALDISCONFIRMED) // yield return AppraiseGoalFailure(hope, fear, goalConduciveness, evt.Id); // } // } //} }
///// <summary> ///// Appraises a Goal's success according to the emotions that the agent is experiencing ///// </summary> ///// <param name="hopeEmotion">the emotion of Hope for achieving the goal that the character feels</param> ///// <param name="fearEmotion">the emotion of Fear for not achieving the goal that the character feels</param> ///// <param name="goalImportance">how important is the goal to the agent</param> ///// <param name="evt">The event that triggered the emotion</param> ///// <returns>the emotion created</returns> //private static OCCBaseEmotion AppraiseGoalSuccess(IActiveEmotion hopeEmotion, IActiveEmotion fearEmotion, float goalImportance, uint evt) { // return AppraiseGoalEnd(OCCEmotionType.Satisfaction,OCCEmotionType.Relief,hopeEmotion,fearEmotion,goalImportance,evt); //} ///// <summary> ///// Appraises a Goal's Failure according to the emotions that the agent is experiencing ///// </summary> ///// <param name="hopeEmotion">the emotion of Hope for achieving the goal that the character feels</param> ///// <param name="fearEmotion">the emotion of Fear for not achieving the goal that the character feels</param> ///// <param name="goalImportance">how important is the goal to the agent</param> ///// <param name="evt">The event that triggered the emotion</param> ///// <returns></returns> //public static OCCBaseEmotion AppraiseGoalFailure(IActiveEmotion hopeEmotion, IActiveEmotion fearEmotion, float goalImportance, uint evt) { // return AppraiseGoalEnd(OCCEmotionType.Disappointment,OCCEmotionType.FearsConfirmed,hopeEmotion,fearEmotion,goalImportance,evt); //} ///// <summary> ///// Appraises a Goal's likelihood of succeeding ///// </summary> ///// <param name="e">The event that triggered the emotion</param> ///// <param name="goalConduciveness">???????</param> ///// <param name="prob">probability of sucess</param> ///// <returns></returns> //public static OCCBaseEmotion AppraiseGoalSuccessProbability(uint evt, float goalConduciveness, float prob) { // return new OCCBaseEmotion(OCCEmotionType.Hope, prob * goalConduciveness, evt); //} ///// <summary> ///// Appraises a Goal's likelihood of failure ///// </summary> ///// <param name="e">The event that triggered the emotion</param> ///// <param name="goalConduciveness">???????</param> ///// <param name="prob">probability of failure</param> ///// <returns></returns> //public static OCCBaseEmotion AppraiseGoalFailureProbability(uint evt, float goalConduciveness, float prob) //{ // return new OCCBaseEmotion(OCCEmotionType.Fear, prob * goalConduciveness, evt); //} public IEnumerable<IEmotion> AffectDerivation(EmotionalAppraisalAsset emotionalModule, IAppraisalFrame frame) { var evt = frame.AppraisedEvent; if(frame.ContainsAppraisalVariable(OCCAppraisalVariables.DESIRABILITY) && frame.ContainsAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS)) { float desirability = frame.GetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY); float praiseworthiness = frame.GetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS); var composedEmotion = OCCAppraiseCompoundEmotions(evt, desirability, praiseworthiness); if (composedEmotion != null) yield return composedEmotion; } if(frame.ContainsAppraisalVariable(OCCAppraisalVariables.DESIRABILITY)) { float desirability = frame.GetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY); if(desirability!=0) { yield return OCCAppraiseWellBeing(evt.Id, desirability); //foreach(string variable in frame.AppraisalVariables.Where(v => v.StartsWith(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER))) //{ // string other = variable.Substring(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER.Length); // float desirabilityForOther = frame.GetAppraisalVariable(variable); // if (desirabilityForOther != 0) // yield return OCCAppraiseFortuneOfOthers(evt.Id, desirability, desirabilityForOther, other); //} } } if(frame.ContainsAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS)) { float praiseworthiness = frame.GetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS); if (praiseworthiness != 0) yield return OCCAppraisePraiseworthiness(evt, praiseworthiness); } //if(frame.ContainsAppraisalVariable(OCCAppraisalVariables.LIKE)) //{ // float like = frame.GetAppraisalVariable(OCCAppraisalVariables.LIKE); // if (like != 0) // yield return OCCAppraiseAttribution(evt, like); //} //if(frame.ContainsAppraisalVariable(OCCAppraisalVariables.GOALCONDUCIVENESS)) //{ // float goalConduciveness = frame.GetAppraisalVariable(OCCAppraisalVariables.GOALCONDUCIVENESS); // if(goalConduciveness!=0) // { // var status = frame.GetAppraisalVariable(OCCAppraisalVariables.GOALSTATUS); // if(status == GOALUNCONFIRMED) // { // float prob = frame.GetAppraisalVariable(OCCAppraisalVariables.SUCCESSPROBABILITY); // if (prob != 0) // yield return AppraiseGoalSuccessProbability(evt.Id, goalConduciveness, prob); // prob = frame.GetAppraisalVariable(OCCAppraisalVariables.FAILUREPROBABILITY); // if (prob != 0) // yield return AppraiseGoalFailureProbability(evt.Id, goalConduciveness, prob); // } // else // { // //TODO find a better way to retrive the active emotions, without allocating extra KB // var fear = emotionalModule.EmotionalState.GetEmotion(new OCCBaseEmotion(OCCEmotionType.Fear, 0, evt.Id)); // var hope = emotionalModule.EmotionalState.GetEmotion(new OCCBaseEmotion(OCCEmotionType.Hope, 0, evt.Id)); // if (status == GOALCONFIRMED) // yield return AppraiseGoalSuccess(hope, fear, goalConduciveness, evt.Id); // else if (status == GOALDISCONFIRMED) // yield return AppraiseGoalFailure(hope, fear, goalConduciveness, evt.Id); // } // } //} }