Changeset 886
- Timestamp:
- 01/25/2011 02:19:14 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
AgentMind/branches/FAtiMA-Modular/FAtiMA.SocialRelations/src/FAtiMA/socialRelations/SocialRelationsComponent.java
r885 r886 14 14 import FAtiMA.Core.IProcessEmotionComponent; 15 15 import FAtiMA.Core.Display.AgentDisplayPanel; 16 import FAtiMA.Core.OCCAffectDerivation.DistressEmotion; 17 import FAtiMA.Core.OCCAffectDerivation.GloatingEmotion; 18 import FAtiMA.Core.OCCAffectDerivation.HappyForEmotion; 19 import FAtiMA.Core.OCCAffectDerivation.JoyEmotion; 16 import FAtiMA.Core.OCCAffectDerivation.OCCAppraisalVariables; 20 17 import FAtiMA.Core.OCCAffectDerivation.OCCComponent; 21 import FAtiMA.Core.OCCAffectDerivation.PittyEmotion; 22 import FAtiMA.Core.OCCAffectDerivation.ReproachEmotion; 23 import FAtiMA.Core.OCCAffectDerivation.ResentmentEmotion; 18 import FAtiMA.Core.OCCAffectDerivation.OCCEmotionType; 24 19 import FAtiMA.Core.emotionalState.ActiveEmotion; 25 20 import FAtiMA.Core.emotionalState.AppraisalFrame; … … 31 26 32 27 33 public class SocialRelationsComponent implements Serializable, IAppraisalDerivationComponent, IModelOfOtherComponent, IProcessEmotionComponent { 34 28 public class SocialRelationsComponent implements Serializable, 29 30 IAppraisalDerivationComponent, IModelOfOtherComponent, 31 32 IProcessEmotionComponent { 33 35 34 /** 36 35 * 37 36 */ 38 37 private static final long serialVersionUID = 1L; 39 38 40 39 public static final String NAME = "SocialRelations"; 41 40 private ArrayList<String> _parsingFiles; 42 43 public SocialRelationsComponent(ArrayList<String> extraParsingFiles) 41 42 public SocialRelationsComponent(ArrayList<String> 43 44 extraParsingFiles) 44 45 { 45 46 _parsingFiles = new ArrayList<String>(); 46 47 _parsingFiles.add(ConfigurationManager.getGoalsFile()); 47 _parsingFiles.add(ConfigurationManager.getPersonalityFile()); 48 _parsingFiles.add(ConfigurationManager.getActionsFile()); 48 _parsingFiles.add 49 50 (ConfigurationManager.getPersonalityFile()); 51 _parsingFiles.add(ConfigurationManager.getActionsFile 52 53 ()); 49 54 _parsingFiles.addAll(extraParsingFiles); 50 55 } 51 56 52 57 private void loadRelations(AgentModel aM){ 53 58 54 AgentLogger.GetInstance().log("LOADING Social Relations: "); 55 RelationsLoaderHandler relationsLoader = new RelationsLoaderHandler(aM); 56 57 try{ 58 SAXParserFactory factory = SAXParserFactory.newInstance(); 59 SAXParser parser = factory.newSAXParser(); 60 61 for(String file : _parsingFiles) 62 { 63 parser.parse(new File(file), relationsLoader); 64 } 65 66 }catch(Exception e){ 67 throw new RuntimeException("Error on Loading the Social Relations XML Files:" + e); 68 } 59 AgentLogger.GetInstance().log("LOADING Social Relations:"); 60 RelationsLoaderHandler relationsLoader = new 61 62 RelationsLoaderHandler(aM); 63 64 try{ 65 SAXParserFactory factory = 66 67 SAXParserFactory.newInstance(); 68 SAXParser parser = factory.newSAXParser(); 69 70 for(String file : _parsingFiles) 71 { 72 parser.parse(new File(file), 73 74 relationsLoader); 75 } 76 77 }catch(Exception e){ 78 throw new RuntimeException("Error on Loading the Social Relations XML Files:" + e); 79 } 69 80 } 70 81 … … 86 97 public void update(AgentModel am, long time) { 87 98 } 88 99 89 100 @Override 90 101 public void update(AgentModel am, Event e) … … 93 104 94 105 @Override 95 public void appraisal(AgentModel am, Event e, AppraisalFrame as) { 96 if(e.GetSubject().equals(Constants.SELF) && e.GetAction().equals("look-at")) 97 { 98 int relationShip = Math.round(LikeRelation.getRelation(Constants.SELF, e.GetTarget()).getValue(am.getMemory())); 106 public void appraisal(AgentModel am, Event e, AppraisalFrame as) 107 108 { 109 if(e.GetSubject().equals(Constants.SELF) && e.GetAction 110 111 ().equals("look-at")) 112 { 113 int relationShip = Math.round 114 115 (LikeRelation.getRelation(Constants.SELF, e.GetTarget()).getValue 116 117 (am.getMemory())); 99 118 if(relationShip != 0) 100 119 { 101 as.SetAppraisalVariable(NAME, (short)7, OCCComponent.LIKE, relationShip); 120 as.SetAppraisalVariable(NAME, (short)7, 121 122 OCCAppraisalVariables.LIKE.name(), relationShip); 102 123 } 103 124 } 104 125 } 105 126 106 127 @Override 107 128 public void inverseAppraisal(AgentModel am, AppraisalFrame af) … … 109 130 float like; 110 131 Event e; 111 like = af.getAppraisalVariable(OCCComponent.LIKE); 112 132 like = af.getAppraisalVariable 133 134 (OCCAppraisalVariables.LIKE.name()); 135 113 136 if(like != 0) 114 137 { 115 138 e = af.getEvent(); 116 LikeRelation.getRelation(Constants.SELF, e.GetTarget()).setValue(am.getMemory(), like); 117 } 118 } 119 139 LikeRelation.getRelation(Constants.SELF, 140 141 e.GetTarget()).setValue(am.getMemory(), like); 142 } 143 } 144 120 145 //updating other's emotional reactions 121 146 122 147 123 148 @Override 124 149 public void emotionActivation(AgentModel am, ActiveEmotion em) { 125 150 Memory m = am.getMemory(); 126 if(em.getType().equals(AdmirationEmotion.getInstance())) 127 { 128 if(em.GetDirection() != null) 129 { 130 LikeRelation.getRelation(Constants.SELF,em.GetDirection().toString()).increment(m,em.GetIntensity()); 131 RespectRelation.getRelation(Constants.SELF,em.GetDirection().toString()).increment(m, em.GetIntensity()); 132 } 133 } 134 else if(em.getType().equals(ReproachEmotion.getInstance())) 135 { 136 if(em.GetDirection() != null) 137 { 138 LikeRelation.getRelation(Constants.SELF,em.GetDirection().toString()).decrement(m, em.GetIntensity()); 139 RespectRelation.getRelation(Constants.SELF,em.GetDirection().toString()).decrement(m, em.GetIntensity()); 140 } 141 } 142 else if(em.getType().equals(HappyForEmotion.getInstance())) 143 { 144 if(em.GetDirection() != null) 145 { 146 LikeRelation.getRelation(Constants.SELF,em.GetDirection().toString()).increment(m, em.GetIntensity()); 147 } 148 } 149 else if(em.getType().equals(GloatingEmotion.getInstance())) 150 { 151 if(em.GetDirection() != null) 152 { 153 LikeRelation.getRelation(Constants.SELF,em.GetDirection().toString()).decrement(m, em.GetIntensity()); 154 } 155 } 156 else if(em.getType().equals(PittyEmotion.getInstance())) 157 { 158 if(em.GetDirection() != null) 159 { 160 LikeRelation.getRelation(Constants.SELF,em.GetDirection().toString()).increment(m, em.GetIntensity()); 161 } 162 } 163 else if(em.getType().equals(ResentmentEmotion.getInstance())) 164 { 165 if(em.GetDirection() != null) 166 { 167 LikeRelation.getRelation(Constants.SELF,em.GetDirection().toString()).decrement(m, em.GetIntensity()); 168 } 169 } 170 else if(em.getType().equals(JoyEmotion.getInstance())) 171 { 172 if(em.GetCause().GetTarget() != null && em.GetCause().GetTarget().equals(Constants.SELF)) 173 { 174 LikeRelation.getRelation(Constants.SELF,em.GetCause().GetSubject()).increment(m, em.GetIntensity()); 175 } 176 } 177 else if(em.getType().equals(DistressEmotion.getInstance())) 178 { 179 if(em.GetCause().GetTarget() != null && em.GetCause().GetTarget().equals(Constants.SELF)) 180 { 181 LikeRelation.getRelation(Constants.SELF,em.GetCause().GetSubject()).decrement(m, em.GetIntensity()); 182 } 183 } 184 } 185 151 if(em.getType().equalsIgnoreCase 152 153 (OCCEmotionType.ADMIRATION.name())) 154 { 155 if(em.GetDirection() != null) 156 { 157 LikeRelation.getRelation 158 159 (Constants.SELF,em.GetDirection().toString()).increment 160 161 (m,em.GetIntensity()); 162 RespectRelation.getRelation 163 164 (Constants.SELF,em.GetDirection().toString()).increment(m, 165 166 em.GetIntensity()); 167 } 168 } 169 else if(em.getType().equalsIgnoreCase 170 171 (OCCEmotionType.REPROACH.name())) 172 { 173 if(em.GetDirection() != null) 174 { 175 LikeRelation.getRelation 176 177 (Constants.SELF,em.GetDirection().toString()).decrement(m, 178 179 em.GetIntensity()); 180 RespectRelation.getRelation 181 182 (Constants.SELF,em.GetDirection().toString()).decrement(m, 183 184 em.GetIntensity()); 185 } 186 } 187 else if(em.getType().equalsIgnoreCase 188 189 (OCCEmotionType.HAPPY_FOR.name())) 190 { 191 if(em.GetDirection() != null) 192 { 193 LikeRelation.getRelation 194 195 (Constants.SELF,em.GetDirection().toString()).increment(m, 196 197 em.GetIntensity()); 198 } 199 } 200 else if(em.getType().equalsIgnoreCase 201 202 (OCCEmotionType.GLOATING.name())) 203 { 204 if(em.GetDirection() != null) 205 { 206 LikeRelation.getRelation 207 208 (Constants.SELF,em.GetDirection().toString()).decrement(m, 209 210 em.GetIntensity()); 211 } 212 } 213 else if(em.getType().equalsIgnoreCase 214 215 (OCCEmotionType.PITTY.name())) 216 { 217 if(em.GetDirection() != null) 218 { 219 LikeRelation.getRelation 220 221 (Constants.SELF,em.GetDirection().toString()).increment(m, 222 223 em.GetIntensity()); 224 } 225 } 226 else if(em.getType().equalsIgnoreCase 227 228 (OCCEmotionType.RESENTMENT.name())) 229 { 230 if(em.GetDirection() != null) 231 { 232 LikeRelation.getRelation 233 234 (Constants.SELF,em.GetDirection().toString()).decrement(m, 235 236 em.GetIntensity()); 237 } 238 } 239 else if(em.getType().equalsIgnoreCase 240 241 (OCCEmotionType.JOY.name())) 242 { 243 if(em.GetCause().GetTarget() != null && 244 245 em.GetCause().GetTarget().equals(Constants.SELF)) 246 { 247 LikeRelation.getRelation 248 249 (Constants.SELF,em.GetCause().GetSubject()).increment(m, 250 251 em.GetIntensity()); 252 } 253 } 254 else if(em.getType().equalsIgnoreCase 255 256 (OCCEmotionType.DISTRESS.name())) 257 { 258 if(em.GetCause().GetTarget() != null && 259 260 em.GetCause().GetTarget().equals(Constants.SELF)) 261 { 262 LikeRelation.getRelation 263 264 (Constants.SELF,em.GetCause().GetSubject()).decrement(m, 265 266 em.GetIntensity()); 267 } 268 } 269 } 270 186 271 187 272 @Override 188 273 public IComponent createModelOfOther() { 189 return new SocialRelationsComponent(new ArrayList<String>()); 274 return new SocialRelationsComponent(new 275 276 ArrayList<String>()); 190 277 } 191 278
Note: See TracChangeset
for help on using the changeset viewer.