Changeset 742
- Timestamp:
- 11/24/2010 11:27:41 PM (10 years ago)
- Location:
- AgentMind/branches/FAtiMA-Modular
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
AgentMind/branches/FAtiMA-Modular/AgentLauncher/.classpath
r730 r742 6 6 <classpathentry combineaccessrules="false" kind="src" path="/FAtiMA.MotivationalSystem"/> 7 7 <classpathentry combineaccessrules="false" kind="src" path="/FAtiMA.SocialRelations"/> 8 <classpathentry combineaccessrules="false" kind="src" path="/FAtiMA.culture"/> 8 9 <classpathentry kind="output" path="bin"/> 9 10 </classpath> -
AgentMind/branches/FAtiMA-Modular/AgentLauncher/src/AgentLauncher.java
r734 r742 1 1 import java.io.IOException; 2 import java.util.ArrayList; 2 3 3 4 import javax.xml.parsers.ParserConfigurationException; … … 9 10 import FAtiMA.Core.exceptions.GoalLibParsingException; 10 11 import FAtiMA.Core.exceptions.UnknownGoalException; 12 import FAtiMA.Core.util.ConfigurationManager; 13 import FAtiMA.Core.util.enumerables.CulturalDimensionType; 14 import FAtiMA.culture.CulturalDimensionsComponent; 11 15 import FAtiMA.motivationalSystem.MotivationalComponent; 12 16 import FAtiMA.socialRelations.SocialRelationsComponent; … … 27 31 28 32 AgentCore aG = initializeAgentCore(args); 29 aG.addComponent(new SocialRelationsComponent()); 30 aG.addComponent(new MotivationalComponent()); 33 ArrayList<String> extraFiles = new ArrayList<String>(); 34 String cultureFile = ConfigurationManager.getMindPath() + ConfigurationManager.getAgentProperties().get("cultureName") + ".xml"; 35 36 extraFiles.add(cultureFile); 37 aG.addComponent(new CulturalDimensionsComponent(cultureFile)); 38 aG.addComponent(new SocialRelationsComponent(extraFiles)); 39 aG.addComponent(new MotivationalComponent(extraFiles)); 40 31 41 32 42 aG.StartAgent(); -
AgentMind/branches/FAtiMA-Modular/FAtiMA.AdvancedMemory/src/main/java/FAtiMA/advancedMemoryComponent/AdvancedMemoryComponent.java
r734 r742 39 39 import javax.xml.parsers.SAXParserFactory; 40 40 41 import FAtiMA.Core.AgentCore;42 41 import FAtiMA.Core.AgentModel; 43 42 import FAtiMA.Core.IComponent; 43 import FAtiMA.Core.IProcessExternalRequestComponent; 44 44 import FAtiMA.Core.Display.AgentDisplayPanel; 45 import FAtiMA.Core.emotionalState.ActiveEmotion;46 45 import FAtiMA.Core.emotionalState.AppraisalStructure; 47 46 import FAtiMA.Core.memory.episodicMemory.ActionDetail; … … 50 49 import FAtiMA.Core.util.AgentLogger; 51 50 import FAtiMA.Core.util.ConfigurationManager; 52 import FAtiMA.Core.wellFormedNames.Name; 53 54 55 public class AdvancedMemoryComponent implements Serializable, IComponent { 51 52 53 public class AdvancedMemoryComponent implements Serializable, IComponent, IProcessExternalRequestComponent { 56 54 57 55 private static final long serialVersionUID = 1L; … … 181 179 182 180 @Override 183 public void decay(long time) { 184 } 185 186 @Override 187 public void update(AgentModel am) { 181 public void updateCycle(AgentModel am, long time) { 188 182 // TODO Auto-generated method stub 189 190 } 191 192 @Override 193 public void update(Event e, AgentModel am) { 183 } 184 185 @Override 186 public void perceiveEvent(AgentModel am, Event e) { 194 187 // TODO Auto-generated method stub 195 188 } 196 189 197 190 @Override 198 public IComponent createModelOfOther() { 199 return null; 200 } 201 202 @Override 203 public void appraisal(Event e, AppraisalStructure as, AgentModel am) { 191 public void appraisal(AgentModel am, Event e, AppraisalStructure as) { 204 192 205 193 //appraisal from memory … … 224 212 225 213 @Override 226 public void emotionActivation(Event e, ActiveEmotion em, AgentModel am) { 227 // TODO Auto-generated method stub 228 229 } 230 231 @Override 232 public void coping(AgentModel am) { 233 // TODO Auto-generated method stub 234 235 } 236 237 @Override 238 public void propertyChangedPerception(String ToM, Name propertyName, 239 String value) { 240 // TODO Auto-generated method stub 241 242 } 243 244 @Override 245 public void lookAtPerception(AgentCore ag, String subject, String target) { 246 // TODO Auto-generated method stub 247 248 } 249 250 @Override 251 public void entityRemovedPerception(String entity) { 252 // TODO Auto-generated method stub 253 254 } 255 256 @Override 257 public AgentDisplayPanel createComponentDisplayPanel(AgentModel am) { 214 public AgentDisplayPanel createDisplayPanel(AgentModel am) { 258 215 return new GeneralMemoryPanel(this); 259 216 } -
AgentMind/branches/FAtiMA-Modular/FAtiMA.MotivationalSystem/src/FAtiMA/motivationalSystem/MotivationalComponent.java
r734 r742 14 14 import javax.xml.parsers.SAXParserFactory; 15 15 16 import FAtiMA.Core.AgentCore;17 16 import FAtiMA.Core.AgentModel; 18 17 import FAtiMA.Core.AgentSimulationTime; 19 18 import FAtiMA.Core.IComponent; 19 import FAtiMA.Core.IModelOfOtherComponent; 20 20 import FAtiMA.Core.Display.AgentDisplayPanel; 21 21 import FAtiMA.Core.deliberativeLayer.IActionFailureStrategy; … … 27 27 import FAtiMA.Core.deliberativeLayer.goals.ActivePursuitGoal; 28 28 import FAtiMA.Core.deliberativeLayer.plan.Step; 29 import FAtiMA.Core.emotionalState.ActiveEmotion;30 29 import FAtiMA.Core.emotionalState.AppraisalStructure; 31 30 import FAtiMA.Core.sensorEffector.Event; … … 45 44 */ 46 45 47 public class MotivationalComponent implements Serializable, Cloneable, IComponent, I ExpectedUtilityStrategy, IProbabilityStrategy, IUtilityStrategy, IGoalSuccessStrategy, IGoalFailureStrategy, IActionFailureStrategy {46 public class MotivationalComponent implements Serializable, Cloneable, IComponent, IModelOfOtherComponent, IExpectedUtilityStrategy, IProbabilityStrategy, IUtilityStrategy, IGoalSuccessStrategy, IGoalFailureStrategy, IActionFailureStrategy { 48 47 49 48 private static final long serialVersionUID = 1L; … … 64 63 protected HashMap<String,ExpectedGoalEffectsOnDrives> _goalEffectsOnDrives; 65 64 protected HashMap<String,ActionEffectsOnDrives> _actionEffectsOnDrives; 65 66 private ArrayList<String> _parsingFiles; 66 67 67 68 public static double determineQuadraticNeedVariation(float currentLevel, float deviation){ … … 86 87 * Creates an empty MotivationalState 87 88 */ 88 public MotivationalComponent( ) {89 public MotivationalComponent(ArrayList<String> extraFiles) { 89 90 _motivators = new Motivator[MotivatorType.numberOfTypes()]; 90 91 _goalTried = 0; … … 94 95 _goalEffectsOnDrives = new HashMap<String,ExpectedGoalEffectsOnDrives>(); 95 96 _actionEffectsOnDrives = new HashMap<String,ActionEffectsOnDrives>(); 97 98 _parsingFiles = new ArrayList<String>(); 99 _parsingFiles.add(ConfigurationManager.getGoalsFile()); 100 _parsingFiles.add(ConfigurationManager.getPersonalityFile()); 101 _parsingFiles.add(ConfigurationManager.getActionsFile()); 102 _parsingFiles.addAll(extraFiles); 96 103 } 97 104 … … 433 440 } 434 441 435 public void update(Event e, AgentModel am) 442 @Override 443 public void perceiveEvent(AgentModel am, Event e) 436 444 { 437 445 float result = UpdateMotivators(am, e); … … 440 448 441 449 @Override 442 public void appraisal( Event e, AppraisalStructure as, AgentModel am) {450 public void appraisal(AgentModel am, Event e, AppraisalStructure as) { 443 451 Float desirability = _appraisals.get(e.toString()); 444 452 if(desirability != null) … … 446 454 as.SetAppraisalVariable(NAME, (short) 8, AppraisalStructure.DESIRABILITY, desirability.floatValue()); 447 455 } 448 }449 450 451 @Override452 public void propertyChangedPerception(String ToM, Name propertyName,453 String value) {454 455 }456 457 458 @Override459 public void lookAtPerception(AgentCore ag, String subject, String target) {460 456 } 461 457 … … 480 476 SAXParserFactory factory = SAXParserFactory.newInstance(); 481 477 SAXParser parser = factory.newSAXParser(); 482 parser.parse(new File(ConfigurationManager.getActionsFile()), needsLoader);483 parser.parse(new File(ConfigurationManager.getGoalsFile()), needsLoader);484 parser.parse(new File(ConfigurationManager.getPersonalityFile()), needsLoader);485 478 479 for(String file : _parsingFiles) 480 { 481 parser.parse(new File(file), needsLoader); 482 } 486 483 487 484 }catch(Exception e){ … … 492 489 493 490 @Override 494 public void update (AgentModel am) {491 public void updateCycle(AgentModel am, long time) { 495 492 _appraisals.clear(); 496 493 } … … 498 495 499 496 @Override 500 public void coping(AgentModel am) {501 }502 503 504 @Override505 public void emotionActivation(Event e, ActiveEmotion em, AgentModel am) {506 }507 508 509 @Override510 public void entityRemovedPerception(String entity) {511 }512 513 514 @Override515 497 public IComponent createModelOfOther() { 516 MotivationalComponent ms = new MotivationalComponent( );498 MotivationalComponent ms = new MotivationalComponent(null); 517 499 Motivator m2; 518 500 … … 529 511 530 512 @Override 531 public AgentDisplayPanel create ComponentDisplayPanel(AgentModel am) {513 public AgentDisplayPanel createDisplayPanel(AgentModel am) { 532 514 return new NeedsPanel(this); 533 515 } … … 575 557 UpdateCertainty(-a.getProbability(am)); 576 558 } 577 578 579 @Override580 public void processExternalRequest(String requestMsg) {581 // TODO Auto-generated method stub582 583 }584 559 } -
AgentMind/branches/FAtiMA-Modular/FAtiMA.SocialRelations/src/FAtiMA/socialRelations/SocialRelationsComponent.java
r734 r742 2 2 3 3 import java.io.File; 4 import java.util.ArrayList; 4 5 5 6 import javax.xml.parsers.SAXParser; 6 7 import javax.xml.parsers.SAXParserFactory; 7 8 8 import FAtiMA.Core.AgentCore;9 9 import FAtiMA.Core.AgentModel; 10 10 import FAtiMA.Core.IComponent; 11 import FAtiMA.Core.IModelOfOtherComponent; 12 import FAtiMA.Core.IProccessEmotionComponent; 11 13 import FAtiMA.Core.Display.AgentDisplayPanel; 12 14 import FAtiMA.Core.emotionalState.ActiveEmotion; … … 18 20 import FAtiMA.Core.util.Constants; 19 21 import FAtiMA.Core.util.enumerables.EmotionType; 20 import FAtiMA.Core.wellFormedNames.Name;21 22 22 23 23 public class SocialRelationsComponent implements IComponent {24 public class SocialRelationsComponent implements IComponent, IModelOfOtherComponent, IProccessEmotionComponent { 24 25 25 26 public static final String NAME = "SocialRelations"; 27 private ArrayList<String> _parsingFiles; 26 28 27 public SocialRelationsComponent() 28 { 29 public SocialRelationsComponent(ArrayList<String> extraParsingFiles) 30 { 31 _parsingFiles = new ArrayList<String>(); 32 _parsingFiles.add(ConfigurationManager.getGoalsFile()); 33 _parsingFiles.add(ConfigurationManager.getPersonalityFile()); 34 _parsingFiles.add(ConfigurationManager.getActionsFile()); 35 _parsingFiles.addAll(extraParsingFiles); 29 36 } 30 37 … … 37 44 SAXParserFactory factory = SAXParserFactory.newInstance(); 38 45 SAXParser parser = factory.newSAXParser(); 39 parser.parse(new File(ConfigurationManager.getActionsFile()),relationsLoader);40 parser.parse(new File(ConfigurationManager.getGoalsFile()),relationsLoader);41 parser.parse(new File(ConfigurationManager.getPersonalityFile()),relationsLoader);42 46 47 for(String file : _parsingFiles) 48 { 49 parser.parse(new File(file), relationsLoader); 50 } 43 51 44 52 }catch(Exception e){ … … 62 70 63 71 @Override 64 public void decay(long time) { 65 } 66 67 @Override 68 public void update(AgentModel am) { 72 public void updateCycle(AgentModel am, long time) { 69 73 } 70 74 71 75 @Override 72 public void update(Event e, AgentModel am)76 public void perceiveEvent(AgentModel am, Event e) 73 77 { 74 78 } 75 79 76 80 @Override 77 public void appraisal( Event e, AppraisalStructure as, AgentModel am) {81 public void appraisal(AgentModel am, Event e, AppraisalStructure as) { 78 82 if(e.GetSubject().equals(Constants.SELF) && e.GetAction().equals("look-at")) 79 83 { … … 87 91 88 92 @Override 89 public void emotionActivation( Event e, ActiveEmotion em, AgentModel am) {93 public void emotionActivation(AgentModel am, Event e, ActiveEmotion em) { 90 94 Memory m = am.getMemory(); 91 95 switch(em.GetType()) … … 160 164 } 161 165 162 163 166 164 167 @Override 165 public void coping(AgentModel am) { 166 // TODO Auto-generated method stub 167 168 public IComponent createModelOfOther() { 169 return new SocialRelationsComponent(null); 168 170 } 169 171 170 172 @Override 171 public void propertyChangedPerception(String ToM, Name propertyName, 172 String value) { 173 // TODO Auto-generated method stub 174 175 } 176 177 @Override 178 public void lookAtPerception(AgentCore ag, String subject, String target) { 179 // TODO Auto-generated method stub 180 181 } 182 183 @Override 184 public void entityRemovedPerception(String entity) { 185 // TODO Auto-generated method stub 186 187 } 188 189 @Override 190 public IComponent createModelOfOther() { 191 return new SocialRelationsComponent(); 192 } 193 194 @Override 195 public AgentDisplayPanel createComponentDisplayPanel(AgentModel am) { 173 public AgentDisplayPanel createDisplayPanel(AgentModel am) { 196 174 return new SocialRelationsPanel(); 197 175 } 198 199 @Override200 public void processExternalRequest(String requestMsg) {201 }202 203 176 } -
AgentMind/branches/FAtiMA-Modular/FAtiMA.ToM/src/FAtiMA/ToM/ModelOfOther.java
r734 r742 10 10 import FAtiMA.Core.IComponent; 11 11 import FAtiMA.Core.IGetModelStrategy; 12 import FAtiMA.Core.IProccessEmotionComponent; 12 13 import FAtiMA.Core.deliberativeLayer.DeliberativeProcess; 13 14 import FAtiMA.Core.emotionalState.ActiveEmotion; … … 33 34 private Memory _mem; 34 35 private HashMap<String,IComponent> _components; 36 private ArrayList<IProccessEmotionComponent> _processEmotionComponents; 35 37 private ReactiveProcess _reactiveProcess; 36 38 private DeliberativeProcess _deliberativeProcess; … … 42 44 _mem = new Memory(); 43 45 _components = new HashMap<String,IComponent>(); 46 _processEmotionComponents = new ArrayList<IProccessEmotionComponent>(); 44 47 45 48 for(EmotionDisposition ed : ag.getEmotionalState().getEmotionDispositions()) … … 72 75 } 73 76 74 public void decay(long time)77 public void updateCycle(long time) 75 78 { 76 _es.Decay();77 78 79 for(IComponent c : _components.values()) 79 80 { 80 c. decay(time);81 c.updateCycle(this,time); 81 82 } 82 83 } 83 84 84 public void update()85 public void perceiveEvent(Event e) 85 86 { 86 87 for(IComponent c : _components.values()) 87 88 { 88 c.update(this); 89 } 90 } 91 92 public void update(Event e) 93 { 94 for(IComponent c : _components.values()) 95 { 96 c.update(e,this); 89 c.perceiveEvent(this,e); 97 90 } 98 91 } … … 105 98 for(IComponent c : this._components.values()) 106 99 { 107 c.appraisal( e,as,this);100 c.appraisal(this,e,as); 108 101 } 109 102 … … 115 108 if(activeEmotion != null) 116 109 { 117 for(I Component c : this._components.values())110 for(IProccessEmotionComponent c : this._processEmotionComponents) 118 111 { 119 c.emotionActivation( e,activeEmotion,this);112 c.emotionActivation(this,e,activeEmotion); 120 113 } 121 114 } … … 135 128 _deliberativeProcess = (DeliberativeProcess) c; 136 129 return; 130 } 131 132 if(c instanceof IProccessEmotionComponent) 133 { 134 _processEmotionComponents.add((IProccessEmotionComponent)c); 137 135 } 138 136 -
AgentMind/branches/FAtiMA-Modular/FAtiMA.ToM/src/FAtiMA/ToM/ModelOfOtherPanel.java
r700 r742 42 42 for(IComponent c: m.getComponents()) 43 43 { 44 panel = c.create ComponentDisplayPanel(m);44 panel = c.createDisplayPanel(m); 45 45 if(panel != null) 46 46 { -
AgentMind/branches/FAtiMA-Modular/FAtiMA.ToM/src/FAtiMA/ToM/ToMComponent.java
r734 r742 8 8 import FAtiMA.Core.IComponent; 9 9 import FAtiMA.Core.IGetModelStrategy; 10 import FAtiMA.Core.IModelOfOtherComponent; 11 import FAtiMA.Core.IProcessPerceptionsComponent; 10 12 import FAtiMA.Core.Display.AgentDisplayPanel; 11 13 import FAtiMA.Core.deliberativeLayer.IGetUtilityForOthers; 12 14 import FAtiMA.Core.deliberativeLayer.goals.ActivePursuitGoal; 13 import FAtiMA.Core.emotionalState.ActiveEmotion;14 15 import FAtiMA.Core.emotionalState.AppraisalStructure; 15 16 import FAtiMA.Core.memory.semanticMemory.KnowledgeSlot; … … 19 20 import FAtiMA.Core.wellFormedNames.Symbol; 20 21 21 public class ToMComponent implements IComponent, I GetModelStrategy, IGetUtilityForOthers {22 public class ToMComponent implements IComponent, IProcessPerceptionsComponent, IGetModelStrategy, IGetUtilityForOthers { 22 23 23 24 public static final String NAME = "ToM"; … … 74 75 for(IComponent c : ag.getComponents()) 75 76 { 76 IComponent componentOfOther = c.createModelOfOther(); 77 if(componentOfOther != null) 77 if(c instanceof IModelOfOtherComponent) 78 78 { 79 model.addComponent(componentOfOther); 79 IComponent componentOfOther = ((IModelOfOtherComponent)c).createModelOfOther(); 80 if(componentOfOther != null) 81 { 82 model.addComponent(componentOfOther); 83 } 80 84 } 81 85 } … … 96 100 97 101 @Override 98 public void decay(long time) { 102 public void updateCycle(AgentModel am,long time) { 103 _appraisalsOfOthers.clear(); 99 104 100 105 for(String s : _nearbyAgents) 101 106 { 102 107 ModelOfOther m = _ToM.get(s); 103 m.decay(time); 104 } 105 } 106 107 @Override 108 public void update(AgentModel am) { 109 _appraisalsOfOthers.clear(); 110 108 m.updateCycle(time); 109 } 110 } 111 112 @Override 113 public void perceiveEvent(AgentModel am, Event e) 114 { 111 115 for(String s : _nearbyAgents) 112 116 { 113 117 ModelOfOther m = _ToM.get(s); 114 m.update(); 115 } 116 } 117 118 @Override 119 public void update(Event e, AgentModel am) 120 { 121 for(String s : _nearbyAgents) 122 { 123 ModelOfOther m = _ToM.get(s); 124 m.update(e); 118 m.perceiveEvent(e); 125 119 } 126 120 } 127 121 128 122 @Override 129 public void appraisal( Event e, AppraisalStructure as, AgentModel am) {123 public void appraisal(AgentModel am, Event e, AppraisalStructure as) { 130 124 131 125 Event e2 = e.RemovePerspective(_name); … … 149 143 as.SetAppraisalOfOther(s, otherAS); 150 144 } 151 }152 153 @Override154 public void emotionActivation(Event e, ActiveEmotion em, AgentModel am) {155 //don't forget to removePerspective if u want to do something here.156 }157 158 @Override159 public void coping(AgentModel am) {160 145 } 161 146 … … 241 226 242 227 @Override 243 public IComponent createModelOfOther() { 244 return null; 245 } 246 247 @Override 248 public AgentDisplayPanel createComponentDisplayPanel(AgentModel am) { 228 public AgentDisplayPanel createDisplayPanel(AgentModel am) { 249 229 return new ToMPanel(this); 250 230 } … … 262 242 return utility; 263 243 } 264 265 @Override266 public void processExternalRequest(String requestMsg) {267 }268 244 } -
AgentMind/branches/FAtiMA-Modular/FAtiMA.culture/src/FAtiMA/culture/CulturalDimensionsComponent.java
r717 r742 10 10 import javax.xml.parsers.SAXParserFactory; 11 11 12 import FAtiMA.Core.AgentCore;13 12 import FAtiMA.Core.AgentModel; 14 13 import FAtiMA.Core.IComponent; … … 20 19 import FAtiMA.Core.deliberativeLayer.IUtilityStrategy; 21 20 import FAtiMA.Core.deliberativeLayer.goals.ActivePursuitGoal; 22 import FAtiMA.Core.emotionalState.ActiveEmotion;23 21 import FAtiMA.Core.emotionalState.AppraisalStructure; 24 22 import FAtiMA.Core.sensorEffector.Event; 25 23 import FAtiMA.Core.util.AgentLogger; 26 24 import FAtiMA.Core.util.Constants; 27 import FAtiMA.Core.util.VersionChecker;28 25 import FAtiMA.Core.util.enumerables.CulturalDimensionType; 29 26 import FAtiMA.Core.wellFormedNames.Name; … … 38 35 final float POWER_DISTANCE_K = 1.2f; 39 36 40 private String culture Name;37 private String cultureFile; 41 38 private int[] _dimensionalValues; 42 39 private ArrayList<Ritual> _rituals; … … 44 41 45 42 46 public CulturalDimensionsComponent(String culture Name){47 this.culture Name = cultureName;43 public CulturalDimensionsComponent(String cultureFile){ 44 this.cultureFile = cultureFile; 48 45 _rituals = new ArrayList<Ritual>(); 49 46 _ritualOptions = new HashMap<String,Ritual>(); … … 64 61 } 65 62 66 public void update(Event e, AgentModel am)63 public void perceiveEvent(AgentModel am, Event e) 67 64 { 68 65 this.addRitualOptions(e,am); … … 70 67 71 68 @Override 72 public void appraisal( Event e, AppraisalStructure as, AgentModel am)69 public void appraisal(AgentModel am, Event e, AppraisalStructure as) 73 70 { 74 71 float desirabilityForOther = 0; … … 142 139 private void loadCulture(AgentModel aM){ 143 140 144 AgentLogger.GetInstance().log("LOADING Culture: " + this.culture Name);141 AgentLogger.GetInstance().log("LOADING Culture: " + this.cultureFile); 145 142 CultureLoaderHandler cultureLoader = new CultureLoaderHandler(aM,this); 146 143 … … 148 145 SAXParserFactory factory = SAXParserFactory.newInstance(); 149 146 SAXParser parser = factory.newSAXParser(); 150 if (VersionChecker.runningOnAndroid()) 151 parser.parse(new File(AgentCore.MIND_PATH_ANDROID + cultureName + ".xml"), cultureLoader); 152 else 153 parser.parse(new File(AgentCore.MIND_PATH + cultureName + ".xml"), cultureLoader); 147 148 parser.parse(new File(this.cultureFile), cultureLoader); 154 149 155 150 for(Ritual r : cultureLoader.GetRituals(aM)){ … … 255 250 public void reset(){} 256 251 257 @Override258 public void decay(long time){}259 @Override260 public void lookAtPerception(AgentCore ag, String subject, String target) {}261 @Override262 public void propertyChangedPerception(String ToM, Name propertyName,String value) {}263 252 264 253 @Override … … 307 296 308 297 @Override 309 public void update (AgentModel am) {298 public void updateCycle(AgentModel am,long time) { 310 299 // TODO Auto-generated method stub 311 300 … … 313 302 314 303 @Override 315 public void coping(AgentModel am) { 316 } 317 318 @Override 319 public void emotionActivation(Event e, ActiveEmotion em, AgentModel am) { 320 // TODO Auto-generated method stub 321 322 } 323 324 @Override 325 public void entityRemovedPerception(String entity) { 326 // TODO Auto-generated method stub 327 328 } 329 330 @Override 331 public IComponent createModelOfOther() { 304 public AgentDisplayPanel createDisplayPanel(AgentModel am) { 332 305 return null; 333 }334 335 @Override336 public AgentDisplayPanel createComponentDisplayPanel(AgentModel am) {337 return null;338 }339 340 @Override341 public void processExternalRequest(String requestMsg) {342 306 } 343 307 } -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/AgentCore.java
r734 r742 63 63 private static final Name ACTION_CONTEXT = Name.ParseName("ActionContext()"); 64 64 65 protected HashMap<String, IComponent> _components; 65 protected HashMap<String, IComponent> _generalComponents; 66 protected ArrayList<IProccessEmotionComponent> _processEmotionComponents; 67 protected ArrayList<IBehaviourComponent> _behaviourComponents; 68 protected ArrayList<IModelOfOtherComponent> _modelOfOtherComponents; 69 protected ArrayList<IProcessExternalRequestComponent> _processExternalRequestComponents; 70 protected ArrayList<IProcessPerceptionsComponent> _processPerceptionsComponents; 71 66 72 protected EmotionalState _emotionalState; 67 73 protected Memory _memory; … … 104 110 _memory.getEpisodicMemory().StartEpisode(_memory); 105 111 _strat = this; 106 _components = new HashMap<String,IComponent>(); 112 113 _generalComponents = new HashMap<String,IComponent>(); 114 _processEmotionComponents = new ArrayList<IProccessEmotionComponent>(); 115 _behaviourComponents = new ArrayList<IBehaviourComponent>(); 116 _modelOfOtherComponents = new ArrayList<IModelOfOtherComponent>(); 117 _processExternalRequestComponents = new ArrayList<IProcessExternalRequestComponent>(); 118 _processPerceptionsComponents = new ArrayList<IProcessPerceptionsComponent>(); 119 107 120 AgentSimulationTime.GetInstance(); //This call will initialize the timer for the agent's simulation time 108 121 } … … 233 246 public void addComponent(IComponent c) 234 247 { 235 this._components.put(c.name(), c); 248 this._generalComponents.put(c.name(), c); 249 if(c instanceof IProccessEmotionComponent) 250 { 251 _processEmotionComponents.add((IProccessEmotionComponent) c); 252 } 253 if(c instanceof IBehaviourComponent) 254 { 255 _behaviourComponents.add((IBehaviourComponent) c); 256 } 257 if(c instanceof IModelOfOtherComponent) 258 { 259 _modelOfOtherComponents.add((IModelOfOtherComponent) c); 260 } 261 if(c instanceof IProcessExternalRequestComponent) 262 { 263 _processExternalRequestComponents.add((IProcessExternalRequestComponent) c); 264 } 265 if(c instanceof IProcessPerceptionsComponent) 266 { 267 _processPerceptionsComponents.add((IProcessPerceptionsComponent) c); 268 } 269 236 270 c.initialize(this); 237 AgentDisplayPanel panel = c.create ComponentDisplayPanel(this);271 AgentDisplayPanel panel = c.createDisplayPanel(this); 238 272 if(panel != null) 239 273 { … … 249 283 public IComponent getComponent(String name) 250 284 { 251 return this._ components.get(name);285 return this._generalComponents.get(name); 252 286 } 253 287 254 288 public Collection<IComponent> getComponents() 255 289 { 256 return this._components.values(); 257 } 258 259 public void RemoveComponent(IComponent c) 290 return this._generalComponents.values(); 291 } 292 293 public Collection<IProcessExternalRequestComponent> getProcessExternalRequestComponents() 294 { 295 return this._processExternalRequestComponents; 296 } 297 298 /*public void RemoveComponent(IComponent c) 260 299 { 261 300 this._components.remove(c.name()); 262 } 301 }*/ 263 302 264 303 … … 352 391 353 392 this._strat = (IGetModelStrategy) s.readObject(); 354 this._components = (HashMap<String,IComponent>) s.readObject(); 393 this._generalComponents = (HashMap<String,IComponent>) s.readObject(); 394 this._processEmotionComponents = (ArrayList<IProccessEmotionComponent>) s.readObject(); 395 this._behaviourComponents = (ArrayList<IBehaviourComponent>) s.readObject(); 396 this._modelOfOtherComponents = (ArrayList<IModelOfOtherComponent>) s.readObject(); 397 this._processExternalRequestComponents = (ArrayList<IProcessExternalRequestComponent>) s.readObject(); 398 this._processPerceptionsComponents = (ArrayList<IProcessPerceptionsComponent>) s.readObject(); 355 399 356 400 s.close(); … … 424 468 } 425 469 426 for(I Component c : this._components.values())470 for(IProcessPerceptionsComponent c : this._processPerceptionsComponents) 427 471 { 428 472 c.lookAtPerception(this, subject, auxTarget); … … 436 480 _memory.getSemanticMemory().Tell(applyPerspective(propertyName, _name), value); 437 481 438 for(I Component c : this._components.values())482 for(IProcessPerceptionsComponent c : this._processPerceptionsComponents) 439 483 { 440 484 c.propertyChangedPerception(ToM, applyPerspective(propertyName, _name), value); … … 475 519 public void PerceiveEntityRemoved(String entity) 476 520 { 477 for(I Component c : this._components.values())521 for(IProcessPerceptionsComponent c : this._processPerceptionsComponents) 478 522 { 479 523 c.entityRemovedPerception(entity); … … 486 530 */ 487 531 public void Reset() { 488 for(IComponent c : this._ components.values())532 for(IComponent c : this._generalComponents.values()) 489 533 { 490 534 c.reset(); … … 533 577 _emotionalState.Decay(); 534 578 535 for(IComponent c : this._ components.values())579 for(IComponent c : this._generalComponents.values()) 536 580 { 537 c.decay(time); 538 c.update(this); 581 c.updateCycle(this, time); 539 582 } 540 583 … … 551 594 552 595 553 for(IComponent c : this._ components.values())596 for(IComponent c : this._generalComponents.values()) 554 597 { 555 c. update(e2,this);598 c.perceiveEvent(this,e2); 556 599 } 557 600 … … 560 603 while(appraisal.hasChanged()) 561 604 { 562 for(IComponent c : this._ components.values())605 for(IComponent c : this._generalComponents.values()) 563 606 { 564 c.appraisal( e2,appraisal,this);607 c.appraisal(this,e2,appraisal); 565 608 566 609 } … … 574 617 if(activeEmotion != null) 575 618 { 576 for(I Component c : this._components.values())619 for(IProccessEmotionComponent c : this._processEmotionComponents) 577 620 { 578 c.emotionActivation( e2,activeEmotion,this);621 c.emotionActivation(this,e2,activeEmotion); 579 622 } 580 623 } … … 612 655 613 656 614 for(I Component c : this._components.values())657 for(IBehaviourComponent c : this._behaviourComponents) 615 658 { 616 659 c.coping(this); … … 730 773 731 774 s.writeObject(_strat); 732 s.writeObject(_components); 775 s.writeObject(_generalComponents); 776 s.writeObject(_processEmotionComponents); 777 s.writeObject(_behaviourComponents); 778 s.writeObject(_modelOfOtherComponents); 779 s.writeObject(_processExternalRequestComponents); 780 s.writeObject(_processPerceptionsComponents); 733 781 734 782 s.flush(); … … 826 874 827 875 s.writeObject(_strat); 828 s.writeObject(_components); 876 s.writeObject(_generalComponents); 877 s.writeObject(_processEmotionComponents); 878 s.writeObject(_behaviourComponents); 879 s.writeObject(_modelOfOtherComponents); 880 s.writeObject(_processExternalRequestComponents); 881 s.writeObject(_processPerceptionsComponents); 829 882 830 883 //s.writeObject(_saveDirectory); … … 879 932 880 933 this._strat = (IGetModelStrategy) s.readObject(); 881 this._components = (HashMap<String,IComponent>) s.readObject(); 934 this._generalComponents = (HashMap<String,IComponent>) s.readObject(); 935 this._processEmotionComponents = (ArrayList<IProccessEmotionComponent>) s.readObject(); 936 this._behaviourComponents = (ArrayList<IBehaviourComponent>) s.readObject(); 937 this._modelOfOtherComponents = (ArrayList<IModelOfOtherComponent>) s.readObject(); 938 this._processExternalRequestComponents = (ArrayList<IProcessExternalRequestComponent>) s.readObject(); 939 this._processPerceptionsComponents = (ArrayList<IProcessPerceptionsComponent>) s.readObject(); 882 940 883 941 AgentSimulationTime.LoadState(s); -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/IComponent.java
r717 r742 2 2 3 3 import FAtiMA.Core.Display.AgentDisplayPanel; 4 import FAtiMA.Core.emotionalState.ActiveEmotion;5 4 import FAtiMA.Core.emotionalState.AppraisalStructure; 6 5 import FAtiMA.Core.sensorEffector.Event; 7 import FAtiMA.Core.wellFormedNames.Name;8 6 9 7 public interface IComponent { … … 15 13 public void reset(); 16 14 17 public void decay(long time);15 public void updateCycle(AgentModel am, long time); 18 16 19 public void update(AgentModel am);17 public void perceiveEvent(AgentModel am, Event e); 20 18 21 public void update(Event e, AgentModel am);19 public void appraisal(AgentModel am, Event e, AppraisalStructure as); 22 20 23 public IComponent createModelOfOther(); 24 25 public void appraisal(Event e, AppraisalStructure as, AgentModel am); 26 27 public void emotionActivation(Event e, ActiveEmotion em, AgentModel am); 28 29 public void coping(AgentModel am); 30 31 public void propertyChangedPerception(String ToM, Name propertyName, String value); 32 33 public void lookAtPerception(AgentCore ag, String subject, String target); 34 35 public void entityRemovedPerception(String entity); 36 37 public AgentDisplayPanel createComponentDisplayPanel(AgentModel am); 38 39 public void processExternalRequest(String requestMsg); 21 public AgentDisplayPanel createDisplayPanel(AgentModel am); 40 22 41 23 } -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/deliberativeLayer/DeliberativeProcess.java
r734 r742 124 124 import java.util.Set; 125 125 126 import FAtiMA.Core.AgentCore;127 126 import FAtiMA.Core.AgentModel; 127 import FAtiMA.Core.IBehaviourComponent; 128 128 import FAtiMA.Core.IComponent; 129 import FAtiMA.Core.IModelOfOtherComponent; 129 130 import FAtiMA.Core.ValuedAction; 130 131 import FAtiMA.Core.Display.AgentDisplayPanel; 131 132 import FAtiMA.Core.conditions.Condition; 132 import FAtiMA.Core.deliberativeLayer.ActionMonitor;133 import FAtiMA.Core.deliberativeLayer.DefaultDetectThreatStrategy;134 import FAtiMA.Core.deliberativeLayer.DefaultStrategy;135 import FAtiMA.Core.deliberativeLayer.EmotionalPlanner;136 import FAtiMA.Core.deliberativeLayer.ExpirableActionMonitor;137 import FAtiMA.Core.deliberativeLayer.IActionFailureStrategy;138 import FAtiMA.Core.deliberativeLayer.IActionSuccessStrategy;139 import FAtiMA.Core.deliberativeLayer.IDetectThreatStrategy;140 import FAtiMA.Core.deliberativeLayer.IExpectedUtilityStrategy;141 import FAtiMA.Core.deliberativeLayer.IGoalFailureStrategy;142 import FAtiMA.Core.deliberativeLayer.IGoalSuccessStrategy;143 import FAtiMA.Core.deliberativeLayer.IOptionsStrategy;144 import FAtiMA.Core.deliberativeLayer.IProbabilityStrategy;145 import FAtiMA.Core.deliberativeLayer.Intention;146 133 import FAtiMA.Core.deliberativeLayer.goals.ActivePursuitGoal; 147 134 import FAtiMA.Core.deliberativeLayer.goals.Goal; … … 172 159 * @author João Dias 173 160 */ 174 public class DeliberativeProcess implements IComponent, I OptionsStrategy, IExpectedUtilityStrategy {161 public class DeliberativeProcess implements IComponent, IBehaviourComponent, IModelOfOtherComponent, IOptionsStrategy, IExpectedUtilityStrategy { 175 162 176 163 /** … … 694 681 */ 695 682 696 697 public void update(Event event, AgentModel am) {683 @Override 684 public void perceiveEvent(AgentModel am, Event event) { 698 685 699 686 CheckLinks(am); … … 895 882 * execution. 896 883 */ 884 @Override 897 885 public void coping(AgentModel am) { 898 886 Intention i = null; … … 1181 1169 * the current intentions and actions. 1182 1170 */ 1171 @Override 1183 1172 public void reset() { 1173 //TODO incomplete 1184 1174 _options.clear(); 1185 1175 _intentions.clear(); … … 1219 1209 } 1220 1210 } 1221 1222 /**1223 * Prepares the deliberative layer for a shutdown1224 */1225 1211 1226 1212 … … 1237 1223 public void initialize(AgentModel ag) { 1238 1224 } 1239 1225 1240 1226 @Override 1241 public void decay(long time) { 1242 // TODO Auto-generated method stub 1243 1244 } 1245 1246 public void update(AgentModel am) 1227 public void updateCycle(AgentModel am, long time) 1247 1228 { 1248 1229 if(_actionMonitor != null && _actionMonitor.Expired()) { … … 1265 1246 } 1266 1247 1267 @Override1268 public void propertyChangedPerception(String ToM, Name propertyName,1269 String value) {1270 }1271 1272 @Override1273 public void lookAtPerception(AgentCore ag, String subject, String target) {1274 }1275 1276 @Override1277 public void emotionActivation(Event e, ActiveEmotion em, AgentModel am) {1278 // TODO Auto-generated method stub1279 1280 }1281 1282 @Override1283 public void entityRemovedPerception(String entity) {1284 // TODO Auto-generated method stub1285 1286 }1287 1248 1288 1249 @Override … … 1292 1253 1293 1254 @Override 1294 public void appraisal( Event e, AppraisalStructure as, AgentModel am) {1255 public void appraisal(AgentModel am, Event e, AppraisalStructure as) { 1295 1256 } 1296 1257 1297 1258 @Override 1298 public AgentDisplayPanel create ComponentDisplayPanel(AgentModel am) {1259 public AgentDisplayPanel createDisplayPanel(AgentModel am) { 1299 1260 return null; 1300 1261 } 1301 1302 @Override1303 public void processExternalRequest(String requestMsg) {1304 }1305 1262 } -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/reactiveLayer/ReactiveProcess.java
r734 r742 62 62 63 63 64 import FAtiMA.Core.AgentCore;65 64 import FAtiMA.Core.AgentModel; 65 import FAtiMA.Core.IBehaviourComponent; 66 66 import FAtiMA.Core.IComponent; 67 import FAtiMA.Core.IModelOfOtherComponent; 67 68 import FAtiMA.Core.ValuedAction; 68 69 import FAtiMA.Core.Display.AgentDisplayPanel; 69 import FAtiMA.Core.emotionalState.ActiveEmotion;70 71 70 import FAtiMA.Core.emotionalState.AppraisalStructure; 72 71 import FAtiMA.Core.sensorEffector.Event; 73 import FAtiMA.Core.wellFormedNames.Name;74 72 75 73 … … 78 76 * @author João Dias 79 77 */ 80 public class ReactiveProcess implements IComponent {78 public class ReactiveProcess implements IComponent, IBehaviourComponent, IModelOfOtherComponent { 81 79 82 80 /** … … 159 157 * reaction rules 160 158 */ 161 public void appraisal(Event event, AppraisalStructure as, AgentModel ag) { 159 @Override 160 public void appraisal(AgentModel ag, Event event, AppraisalStructure as) { 162 161 Reaction selfEvaluation; 163 162 … … 190 189 * according to the emotional state. 191 190 */ 191 @Override 192 192 public void coping(AgentModel am) { 193 193 ValuedAction action; … … 267 267 268 268 @Override 269 public void decay(long time) { 270 } 271 272 @Override 273 public void update(AgentModel am) { 274 } 275 276 @Override 277 public void update(Event e, AgentModel am) 278 { 279 } 280 281 @Override 282 public void propertyChangedPerception(String ToM, Name propertyName, 283 String value) { 284 } 285 286 @Override 287 public void lookAtPerception(AgentCore ag, String subject, String target) { 288 } 289 290 @Override 291 public void emotionActivation(Event e, ActiveEmotion em, AgentModel am) { 292 // TODO Auto-generated method stub 293 294 } 295 296 @Override 297 public void entityRemovedPerception(String entity) { 298 // TODO Auto-generated method stub 299 300 } 301 269 public void updateCycle(AgentModel am,long time) { 270 } 271 272 @Override 273 public void perceiveEvent(AgentModel am, Event e) 274 { 275 } 276 277 302 278 @Override 303 279 public IComponent createModelOfOther() { … … 312 288 313 289 @Override 314 public AgentDisplayPanel create ComponentDisplayPanel(AgentModel am) {290 public AgentDisplayPanel createDisplayPanel(AgentModel am) { 315 291 return null; 316 292 } 317 318 @Override319 public void processExternalRequest(String requestMsg) {320 }321 293 } -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/sensorEffector/RemoteAgent.java
r731 r742 90 90 import FAtiMA.Core.AgentSimulationTime; 91 91 import FAtiMA.Core.IComponent; 92 import FAtiMA.Core.IProcessExternalRequestComponent; 92 93 import FAtiMA.Core.ValuedAction; 93 94 import FAtiMA.Core.emotionalState.EmotionalState; … … 324 325 else 325 326 { 326 for(I Component c : _agent.getComponents())327 for(IProcessExternalRequestComponent c : _agent.getProcessExternalRequestComponents()) 327 328 { 328 if(msgType.equals( c.name()))329 if(msgType.equals(((IComponent)c).name())) 329 330 { 330 331 c.processExternalRequest(perception); -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/util/ConfigurationManager.java
r731 r742 110 110 } 111 111 112 public static String getMindPath() 113 { 114 if(VersionChecker.runningOnAndroid()) 115 { 116 return AgentCore.MIND_PATH_ANDROID; 117 } 118 else 119 { 120 return AgentCore.MIND_PATH_ANDROID; 121 } 122 } 123 112 124 public static String getName(){ 113 125 return getInstance().getConfigurationValue(NAME);
Note: See TracChangeset
for help on using the changeset viewer.