Changeset 734
- Timestamp:
- 11/23/2010 02:24:45 PM (10 years ago)
- Location:
- AgentMind/branches/FAtiMA-Modular
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
AgentMind/branches/FAtiMA-Modular/AgentLauncher/src/AgentLauncher.java
r730 r734 9 9 import FAtiMA.Core.exceptions.GoalLibParsingException; 10 10 import FAtiMA.Core.exceptions.UnknownGoalException; 11 import FAtiMA.motivationalSystem.MotivationalComponent; 11 12 import FAtiMA.socialRelations.SocialRelationsComponent; 12 13 … … 27 28 AgentCore aG = initializeAgentCore(args); 28 29 aG.addComponent(new SocialRelationsComponent()); 30 aG.addComponent(new MotivationalComponent()); 29 31 30 32 aG.StartAgent(); -
AgentMind/branches/FAtiMA-Modular/FAtiMA.AdvancedMemory/src/main/java/FAtiMA/advancedMemoryComponent/AdvancedMemoryComponent.java
r730 r734 203 203 public void appraisal(Event e, AppraisalStructure as, AgentModel am) { 204 204 205 Event event2;206 207 //self evaluation208 event2 = e.ApplyPerspective(am.getName());209 210 205 //appraisal from memory 211 ActionDetail ad = new ActionDetail(0,e vent2.GetSubject(),212 e vent2.GetAction(),213 e vent2.GetTarget(),214 e vent2.GetParameters(),null,null,null,null);206 ActionDetail ad = new ActionDetail(0,e.GetSubject(), 207 e.GetAction(), 208 e.GetTarget(), 209 e.GetParameters(),null,null,null,null); 215 210 216 211 _compoundCue.Match(ad,am.getMemory().getEpisodicMemory()); -
AgentMind/branches/FAtiMA-Modular/FAtiMA.MotivationalSystem/src/FAtiMA/motivationalSystem/MotivationalComponent.java
r725 r734 6 6 7 7 8 import java.io.File; 8 9 import java.io.Serializable; 9 10 import java.util.ArrayList; 10 11 import java.util.HashMap; 12 13 import javax.xml.parsers.SAXParser; 14 import javax.xml.parsers.SAXParserFactory; 11 15 12 16 import FAtiMA.Core.AgentCore; … … 27 31 import FAtiMA.Core.sensorEffector.Event; 28 32 import FAtiMA.Core.util.AgentLogger; 33 import FAtiMA.Core.util.ConfigurationManager; 34 import FAtiMA.Core.util.Constants; 29 35 import FAtiMA.Core.wellFormedNames.Name; 30 36 import FAtiMA.Core.wellFormedNames.Substitution; … … 87 93 _appraisals = new HashMap<String,Float>(); 88 94 _goalEffectsOnDrives = new HashMap<String,ExpectedGoalEffectsOnDrives>(); 95 _actionEffectsOnDrives = new HashMap<String,ActionEffectsOnDrives>(); 89 96 } 90 97 … … 166 173 target = (Symbol) eff.getTarget().clone(); 167 174 target.MakeGround(substitutions); 168 if(target.toString().equals( am.getName()))175 if(target.toString().equals(Constants.SELF)) 169 176 { 170 177 AgentLogger.GetInstance().log("Updating motivator " + eff.getDriveName()); … … 194 201 float currentIntensity = 0; 195 202 float auxMultiplier = 1; 203 boolean test; 196 204 197 205 try { … … 199 207 200 208 ExpectedGoalEffectsOnDrives effects = _goalEffectsOnDrives.get(g.getKey()); 209 if(effects == null) return 0; 201 210 for(EffectOnDrive e : effects.getEffects()) 202 211 { 203 Symbol target = (Symbol) e.getTarget().clone(); 204 target.MakeGround(g.getAppliedSubstitutions()); 205 if(target.toString().equals(am.getName())) 212 if(am.isSelf()) 213 { 214 test = e.getTarget().toString().equals(Constants.SELF); 215 } 216 else 217 { 218 Symbol target = (Symbol) e.getTarget().clone(); 219 target.MakeGround(g.getAppliedSubstitutions()); 220 test = target.toString().equals(am.getName()); 221 } 222 223 if(test) 206 224 { 207 225 expectedContribution = e.getValue(); … … 417 435 public void update(Event e, AgentModel am) 418 436 { 419 Event event2 = e.ApplyPerspective(am.getName()); 420 float result = UpdateMotivators(am, event2); 437 float result = UpdateMotivators(am, e); 421 438 _appraisals.put(e.toString(), new Float(result)); 422 439 } … … 452 469 am.getDeliberativeLayer().addGoalFailureStrategy(this); 453 470 am.getDeliberativeLayer().addGoalSuccessStrategy(this); 471 LoadNeeds(am); 472 } 473 474 private void LoadNeeds(AgentModel am) 475 { 476 AgentLogger.GetInstance().log("LOADING Social Relations: "); 477 NeedsLoaderHandler needsLoader = new NeedsLoaderHandler(am,this); 478 479 try{ 480 SAXParserFactory factory = SAXParserFactory.newInstance(); 481 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 486 487 }catch(Exception e){ 488 throw new RuntimeException("Error on Loading Needs from XML Files:" + e); 489 } 454 490 } 455 491 -
AgentMind/branches/FAtiMA-Modular/FAtiMA.MotivationalSystem/src/FAtiMA/motivationalSystem/NeedsLoaderHandler.java
r720 r734 3 3 import org.xml.sax.Attributes; 4 4 5 import FAtiMA.Core.Agent Core;5 import FAtiMA.Core.AgentModel; 6 6 import FAtiMA.Core.util.AgentLogger; 7 import FAtiMA.Core.util.Constants; 7 8 import FAtiMA.Core.util.parsers.ReflectXMLHandler; 9 import FAtiMA.Core.wellFormedNames.Substitution; 8 10 import FAtiMA.Core.wellFormedNames.Symbol; 9 11 10 12 public class NeedsLoaderHandler extends ReflectXMLHandler { 11 13 12 Agent Core_agent;14 AgentModel _agent; 13 15 String _currentGoalKey; 14 16 String _currentStepKey; 15 17 16 18 17 public NeedsLoaderHandler(Agent Coreagent, MotivationalComponent motivationalState){19 public NeedsLoaderHandler(AgentModel agent, MotivationalComponent motivationalState){ 18 20 this._agent = agent; 19 21 } … … 40 42 } 41 43 44 public void ActivePursuitGoal(Attributes attributes) { 45 _currentGoalKey = attributes.getValue("name"); 46 } 47 public void InterestGoal(Attributes attributes) 48 { 49 _currentGoalKey = attributes.getValue("name"); 50 } 51 42 52 public void Action(Attributes attributes){ 43 53 _currentStepKey = attributes.getValue("name"); … … 52 62 String target = attributes.getValue("target"); 53 63 54 if(driveName != null && _current GoalKey != null){64 if(driveName != null && _currentStepKey != null){ 55 65 motivComp.addActionEffectsOnDrive(_currentStepKey, driveName, new Symbol(target), Float.parseFloat(value)); 56 66 } … … 73 83 String value = attributes.getValue("value"); 74 84 String target = attributes.getValue("target"); 85 Symbol t = new Symbol(target); 86 Substitution self = new Substitution(new Symbol("[SELF]"), new Symbol(Constants.SELF)); 87 t.MakeGround(self); 75 88 76 89 if(driveName != null && _currentGoalKey != null){ 77 ms.addExpectedGoalEffectOnDrive(_currentGoalKey, effectType, driveName, new Symbol(target), Float.parseFloat(value));90 ms.addExpectedGoalEffectOnDrive(_currentGoalKey, effectType, driveName, t, Float.parseFloat(value)); 78 91 } 79 92 } -
AgentMind/branches/FAtiMA-Modular/FAtiMA.SocialRelations/src/FAtiMA/socialRelations/SocialRelationsComponent.java
r717 r734 1 1 package FAtiMA.socialRelations; 2 3 import java.io.File; 4 5 import javax.xml.parsers.SAXParser; 6 import javax.xml.parsers.SAXParserFactory; 2 7 3 8 import FAtiMA.Core.AgentCore; … … 9 14 import FAtiMA.Core.memory.Memory; 10 15 import FAtiMA.Core.sensorEffector.Event; 16 import FAtiMA.Core.util.AgentLogger; 17 import FAtiMA.Core.util.ConfigurationManager; 11 18 import FAtiMA.Core.util.Constants; 12 19 import FAtiMA.Core.util.enumerables.EmotionType; 13 20 import FAtiMA.Core.wellFormedNames.Name; 14 21 22 15 23 public class SocialRelationsComponent implements IComponent { 16 24 … … 20 28 { 21 29 } 30 31 private void loadRelations(AgentModel aM){ 32 33 AgentLogger.GetInstance().log("LOADING Social Relations: "); 34 RelationsLoaderHandler relationsLoader = new RelationsLoaderHandler(aM); 35 36 try{ 37 SAXParserFactory factory = SAXParserFactory.newInstance(); 38 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 43 44 }catch(Exception e){ 45 throw new RuntimeException("Error on Loading the Social Relations XML Files:" + e); 46 } 47 } 22 48 23 49 @Override … … 27 53 28 54 @Override 29 public void initialize(AgentModel am) { 55 public void initialize(AgentModel am) { 56 this.loadRelations(am); 30 57 } 31 58 … … 52 79 { 53 80 int relationShip = Math.round(LikeRelation.getRelation(Constants.SELF, e.GetTarget()).getValue(am.getMemory())); 54 as.SetAppraisalVariable(NAME, (short)7, AppraisalStructure.LIKE, relationShip); 81 if(relationShip != 0) 82 { 83 as.SetAppraisalVariable(NAME, (short)7, AppraisalStructure.LIKE, relationShip); 84 } 55 85 } 56 86 } … … 129 159 } 130 160 } 161 162 131 163 132 164 @Override -
AgentMind/branches/FAtiMA-Modular/FAtiMA.ToM/src/FAtiMA/ToM/ModelOfOther.java
r700 r734 47 47 _es.AddEmotionDisposition(ed); 48 48 } 49 } 50 51 public boolean isSelf() 52 { 53 return false; 49 54 } 50 55 -
AgentMind/branches/FAtiMA-Modular/FAtiMA.ToM/src/FAtiMA/ToM/ToMComponent.java
r717 r734 29 29 30 30 31 public ToMComponent(String name)32 { 33 this._name = name;31 public ToMComponent(String agentName) 32 { 33 this._name = agentName; 34 34 this._nearbyAgents = new ArrayList<String>(); 35 35 this._appraisalsOfOthers = new HashMap<Event,AppraisalStructure>(); … … 129 129 public void appraisal(Event e, AppraisalStructure as, AgentModel am) { 130 130 131 Event e2 = e.RemovePerspective(_name); 132 Event e3; 133 131 134 //one time appraisal for each event, so if the event was already appraised this cycle, just return 132 if(_appraisalsOfOthers.containsKey(e ))135 if(_appraisalsOfOthers.containsKey(e2)) 133 136 { 134 137 return; … … 141 144 otherAS = new AppraisalStructure(); 142 145 ModelOfOther m = _ToM.get(s); 143 m.appraisal(e, otherAS); 146 e3 = e2.ApplyPerspective(s); 147 m.appraisal(e3, otherAS); 144 148 145 149 as.SetAppraisalOfOther(s, otherAS); … … 149 153 @Override 150 154 public void emotionActivation(Event e, ActiveEmotion em, AgentModel am) { 151 155 //don't forget to removePerspective if u want to do something here. 152 156 } 153 157 … … 171 175 public void propertyChangedPerception(String ToM, Name propertyName, String value) 172 176 { 177 Name propertyName2 = AgentCore.removePerspective(propertyName, _name); 178 179 173 180 if(ToM.equals(Constants.UNIVERSAL.toString())) 174 181 { … … 176 183 { 177 184 ModelOfOther m = _ToM.get(other); 178 m.getMemory().getSemanticMemory().Tell(AgentCore.applyPerspective(propertyName ,other), value);185 m.getMemory().getSemanticMemory().Tell(AgentCore.applyPerspective(propertyName2,other), value); 179 186 } 180 187 } … … 184 191 if(m != null) 185 192 { 186 m.getMemory().getSemanticMemory().Tell(AgentCore.applyPerspective(propertyName ,ToM), value);193 m.getMemory().getSemanticMemory().Tell(AgentCore.applyPerspective(propertyName2,ToM), value); 187 194 } 188 195 } -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/AgentCore.java
r730 r734 193 193 } 194 194 195 196 197 198 195 public static Name applyPerspective(Name n, String agentName) 199 196 { … … 210 207 211 208 return newName; 209 } 210 211 public static Name removePerspective(Name n, String agentName) 212 { 213 Name newName = (Name) n.clone(); 214 ArrayList<Symbol> symbols = newName.GetLiteralList(); 215 216 for(int i = 0; i < symbols.size(); i++) 217 { 218 if(symbols.get(i).getName().equals(Constants.SELF)) 219 { 220 symbols.set(i, new Symbol(agentName)); 221 } 222 } 223 224 return newName; 225 } 226 227 public boolean isSelf() 228 { 229 return true; 212 230 } 213 231 … … 535 553 for(IComponent c : this._components.values()) 536 554 { 537 c.update(e ,this);555 c.update(e2,this); 538 556 } 539 557 … … 544 562 for(IComponent c : this._components.values()) 545 563 { 546 c.appraisal(e ,appraisal,this);564 c.appraisal(e2,appraisal,this); 547 565 548 566 } 549 567 } 550 568 551 emotions = Appraisal.GenerateEmotions(this, e , appraisal);569 emotions = Appraisal.GenerateEmotions(this, e2, appraisal); 552 570 553 571 for(BaseEmotion em : emotions) … … 558 576 for(IComponent c : this._components.values()) 559 577 { 560 c.emotionActivation(e ,activeEmotion,this);578 c.emotionActivation(e2,activeEmotion,this); 561 579 } 562 580 } -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/AgentModel.java
r717 r734 28 28 public IComponent getComponent(String name); 29 29 30 public boolean isSelf(); 31 30 32 } -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/deliberativeLayer/DeliberativeProcess.java
r717 r734 694 694 */ 695 695 696 /**697 * Deliberative appraisal process. Checks goal activation and698 * inserts intentions to achieve recently activated goals. Generates699 * initial Hope/Fear emotions for each activated goal.700 * @throws InvalidMotivatorTypeException701 */702 703 /*public void AppraiseForOthers(Event event, AgentModel am)704 {705 Event event2 = event.ApplyPerspective(am.getName());706 am.getMotivationalState().UpdateMotivators(am, event2, _planner.GetOperators());707 }*/708 696 709 697 public void update(Event event, AgentModel am) { 710 698 711 699 CheckLinks(am); 712 713 //updating selfMotivators 714 Event event2 = event.ApplyPerspective(am.getName()); 715 716 if(_actionMonitor != null && _actionMonitor.MatchEvent(event2)) { 700 701 702 if(_actionMonitor != null && _actionMonitor.MatchEvent(event)) { 717 703 if(_actionMonitor.GetStep().getAgent().isGrounded() && 718 704 !_actionMonitor.GetStep().getAgent().toString().equals("SELF")) … … 721 707 //since the step of another agent may contain unbound variables, 722 708 //we cannot just compare the names, we need to try to unify them 723 if(Unifier.Unify(event 2.toStepName(),709 if(Unifier.Unify(event.toStepName(), 724 710 _actionMonitor.GetStep().getName()) != null) 725 711 { -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/deliberativeLayer/goals/ActivePursuitGoal.java
r732 r734 557 557 g._goalID = this._goalID; 558 558 g._id = this._id; 559 g._key = this._key; 559 560 g._active = this._active; 560 561 g._name = (Name) this._name.clone(); -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/emotionalState/AppraisalStructure.java
r730 r734 70 70 } 71 71 72 public booleanSetAppraisalVariable(String component, short weight, short appraisalVariable, float value)72 public void SetAppraisalVariable(String component, short weight, short appraisalVariable, float value) 73 73 { 74 74 HashMap<String,Pair> a = _appraisal.get(appraisalVariable); … … 85 85 //nothing else needs to be done in this case 86 86 } 87 return _changed;88 87 } 89 //setting up a new value 90 Pair p = new Pair(weight, value); 91 _weights[appraisalVariable] += weight; 92 a.put(component,p); 93 _empty = false; 94 _changed = true; 95 return _changed; 88 else 89 { 90 //setting up a new value 91 Pair p = new Pair(weight, value); 92 _weights[appraisalVariable] += weight; 93 a.put(component,p); 94 _empty = false; 95 _changed = true; 96 } 96 97 } 97 98 … … 110 111 111 112 _empty = false; 112 _changed = as. SetAppraisalVariable(component, weight, appraisalVariable, value);113 _changed = as.hasChanged(); 113 114 } 114 115 … … 165 166 boolean aux = _changed; 166 167 _changed = false; 167 for(AppraisalStructure as : _appraisalOfOthers.values()) 168 { 169 as.hasChanged(); 170 } 168 171 169 return aux; 172 170 } -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/reactiveLayer/ReactiveProcess.java
r730 r734 160 160 */ 161 161 public void appraisal(Event event, AppraisalStructure as, AgentModel ag) { 162 Event event2;163 162 Reaction selfEvaluation; 164 163 165 //self evaluation 166 event2 = event.ApplyPerspective(ag.getName()); 167 selfEvaluation = Evaluate(ag, event2); 164 165 selfEvaluation = Evaluate(ag, event); 168 166 169 167 if(selfEvaluation != null) -
AgentMind/branches/FAtiMA-Modular/LIRECOptionsAmy.txt
r300 r734 19 19 Amy Hug Jonas 20 20 Amy Massage Jonas 21 Amy Slap Greta
Note: See TracChangeset
for help on using the changeset viewer.