Changeset 926
- Timestamp:
- 02/06/2011 11:16:53 PM (10 years ago)
- Location:
- AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core
- Files:
-
- 9 added
- 8 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/AgentCore.java
r896 r926 26 26 import FAtiMA.Core.Display.AgentDisplayPanel; 27 27 import FAtiMA.Core.OCCAffectDerivation.OCCComponent; 28 import FAtiMA.Core.componentTypes.IAdvancedPerceptionsComponent; 29 import FAtiMA.Core.componentTypes.IAffectDerivationComponent; 30 import FAtiMA.Core.componentTypes.IAppraisalDerivationComponent; 31 import FAtiMA.Core.componentTypes.IBehaviourComponent; 32 import FAtiMA.Core.componentTypes.IComponent; 33 import FAtiMA.Core.componentTypes.IModelOfOtherComponent; 34 import FAtiMA.Core.componentTypes.IProcessEmotionComponent; 35 import FAtiMA.Core.componentTypes.IProcessExternalRequestComponent; 28 36 import FAtiMA.Core.deliberativeLayer.DeliberativeProcess; 29 37 import FAtiMA.Core.deliberativeLayer.EmotionalPlanner; -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/AgentModel.java
r848 r926 1 1 package FAtiMA.Core; 2 2 3 import FAtiMA.Core.componentTypes.IComponent; 3 4 import FAtiMA.Core.deliberativeLayer.DeliberativeProcess; 4 5 import FAtiMA.Core.emotionalState.AppraisalFrame; -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/OCCAffectDerivation/OCCComponent.java
r922 r926 5 5 6 6 import FAtiMA.Core.AgentModel; 7 import FAtiMA.Core.IAffectDerivationComponent;8 import FAtiMA.Core.IComponent;9 import FAtiMA.Core.IModelOfOtherComponent;10 7 import FAtiMA.Core.Display.AgentDisplayPanel; 8 import FAtiMA.Core.componentTypes.IAffectDerivationComponent; 9 import FAtiMA.Core.componentTypes.IComponent; 10 import FAtiMA.Core.componentTypes.IModelOfOtherComponent; 11 11 import FAtiMA.Core.emotionalState.ActiveEmotion; 12 12 import FAtiMA.Core.emotionalState.AppraisalFrame; -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/deliberativeLayer/ActionMonitor.java
r667 r926 34 34 35 35 import java.io.Serializable; 36 import java.util.ArrayList; 36 37 38 import FAtiMA.Core.AgentModel; 39 import FAtiMA.Core.conditions.Condition; 37 40 import FAtiMA.Core.deliberativeLayer.plan.Step; 38 41 import FAtiMA.Core.sensorEffector.Event; 42 import FAtiMA.Core.wellFormedNames.SubstitutionSet; 39 43 40 44 … … 69 73 * @return - the monitored step 70 74 */ 71 public Step GetStep() {75 public Step getStep() { 72 76 return _step; 73 77 } … … 80 84 * monitored action, false otherwise 81 85 */ 82 public boolean MatchEvent(Event e) {86 public boolean matchEvent(Event e) { 83 87 return Event.MatchEvent(_event,e); 84 88 } … … 89 93 * @return allways returns false 90 94 */ 91 public boolean Expired() {95 public boolean expired() { 92 96 return false; 97 } 98 99 /** 100 * indicates if the action's preconditions are verified and the action can thus complete 101 * if the action's preconditions are not verified, then it means that the action will fail 102 * @return 103 */ 104 public boolean checkPreconditions(AgentModel am) 105 { 106 ArrayList<SubstitutionSet> ss = Condition.CheckActivation(am, _step.getPreconditions()); 107 108 return ss != null; 93 109 } 94 110 -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/deliberativeLayer/DeliberativeProcess.java
r911 r926 126 126 127 127 import FAtiMA.Core.AgentModel; 128 import FAtiMA.Core.IAppraisalDerivationComponent;129 import FAtiMA.Core.IBehaviourComponent;130 import FAtiMA.Core.IComponent;131 import FAtiMA.Core.IModelOfOtherComponent;132 128 import FAtiMA.Core.ValuedAction; 133 129 import FAtiMA.Core.Display.AgentDisplayPanel; 130 import FAtiMA.Core.componentTypes.IAppraisalDerivationComponent; 131 import FAtiMA.Core.componentTypes.IBehaviourComponent; 132 import FAtiMA.Core.componentTypes.IComponent; 133 import FAtiMA.Core.componentTypes.IModelOfOtherComponent; 134 134 import FAtiMA.Core.conditions.Condition; 135 135 import FAtiMA.Core.deliberativeLayer.goals.ActivePursuitGoal; … … 148 148 import FAtiMA.Core.sensorEffector.Parameter; 149 149 import FAtiMA.Core.util.AgentLogger; 150 import FAtiMA.Core.util.Constants; 150 151 import FAtiMA.Core.wellFormedNames.Name; 151 152 import FAtiMA.Core.wellFormedNames.Substitution; … … 690 691 691 692 692 if(_actionMonitor != null && _actionMonitor. MatchEvent(event)) {693 if(_actionMonitor. GetStep().getAgent().isGrounded() &&694 !_actionMonitor. GetStep().getAgent().toString().equals("SELF"))693 if(_actionMonitor != null && _actionMonitor.matchEvent(event)) { 694 if(_actionMonitor.getStep().getAgent().isGrounded() && 695 !_actionMonitor.getStep().getAgent().toString().equals(Constants.SELF)) 695 696 { 696 697 //the agent was waiting for an action of other agent to be complete … … 698 699 //we cannot just compare the names, we need to try to unify them 699 700 if(Unifier.Unify(event.toStepName(), 700 _actionMonitor. GetStep().getName()) != null)701 _actionMonitor.getStep().getName()) != null) 701 702 { 702 _actionMonitor. GetStep().IncreaseProbability(am);703 _actionMonitor.getStep().IncreaseProbability(am); 703 704 //System.out.println("Calling updateEffectsProbability (other's action: step completed)"); 704 _actionMonitor. GetStep().updateEffectsProbability(am);705 _actionMonitor.getStep().updateEffectsProbability(am); 705 706 } 706 707 else … … 708 709 for(IActionFailureStrategy s : _actionFailureStrategies) 709 710 { 710 s.perceiveActionFailure(am, _actionMonitor. GetStep());711 s.perceiveActionFailure(am, _actionMonitor.getStep()); 711 712 } 712 713 713 _actionMonitor. GetStep().DecreaseProbability(am);714 _actionMonitor.getStep().DecreaseProbability(am); 714 715 } 715 716 } … … 718 719 for(IActionSuccessStrategy s : _actionSuccessStrategies) 719 720 { 720 s.perceiveActionSuccess(am, _actionMonitor. GetStep());721 s.perceiveActionSuccess(am, _actionMonitor.getStep()); 721 722 } 722 723 //System.out.println("Calling updateEffectsProbability (self: step completed)"); 723 _actionMonitor. GetStep().updateEffectsProbability(am);724 _actionMonitor.getStep().updateEffectsProbability(am); 724 725 } 725 726 … … 787 788 float EU; 788 789 789 790 791 790 maxUtility = -200; 792 791 … … 930 929 { 931 930 RemoveIntention(i); 932 _actionMonitor = null;933 931 for(IGoalSuccessStrategy s: _goalSuccessStrategies) 934 932 { 935 933 s.perceiveGoalSuccess(am, i.getGoal()); 936 934 } 937 i.ProcessIntentionSuccess(am); 935 i.ProcessIntentionSuccess(am); 936 cancelAction(am); 938 937 } 939 938 else if(i.getGoal().CheckFailure(am)) 940 939 { 941 940 RemoveIntention(i); 942 943 _actionMonitor = null;944 941 for(IGoalFailureStrategy s: _goalFailureStrategies) 945 942 { … … 947 944 } 948 945 i.ProcessIntentionFailure(am); 946 cancelAction(am); 949 947 } 950 948 else if(i.NumberOfAlternativePlans() == 0) … … 956 954 i.ProcessIntentionFailure(am); 957 955 _currentIntention = null; 956 //we need to maintain the goal failure in memory (remembering there is no way to achieve the goal) 957 //if there is no strong commitment 958 958 if(i.IsStrongCommitment()) 959 959 { 960 RemoveIntention(i); 961 } 962 cancelAction(am); 963 } 964 else if(!i.getGoal().checkPreconditions(am)) 965 { 966 //this is done only if the agent hasn't tried to do anything yet, he cancels the goal out 967 //if the preconditions are not yet established 968 if(!i.IsStrongCommitment()) 969 { 960 970 RemoveIntention(i); 961 _actionMonitor = null;962 }963 }964 else if(!i.getGoal().checkPreconditions(am))965 {966 RemoveIntention(i);967 if(i.IsStrongCommitment())968 {969 //if(_selectedAction != null)970 {971 am.getRemoteAgent().cancelAction();972 _actionMonitor = null;973 _selectedAction = null;974 }975 976 i.ProcessIntentionCancel(am);977 971 } 978 972 } … … 1061 1055 } 1062 1056 1057 private void cancelAction(AgentModel am) 1058 { 1059 if(_actionMonitor!=null) 1060 { 1061 if(_actionMonitor.getStep().getAgent().toString().equals(Constants.SELF)) 1062 { 1063 am.getRemoteAgent().cancelAction(); 1064 } 1065 _actionMonitor = null; 1066 } 1067 1068 _selectedAction = null; 1069 } 1070 1063 1071 public void AppraiseSelfActionFailed(Event e) 1064 1072 { 1065 1073 if(_actionMonitor != null) 1066 1074 { 1067 if(_actionMonitor. MatchEvent(e))1075 if(_actionMonitor.matchEvent(e)) 1068 1076 { 1069 1077 _actionMonitor = null; … … 1100 1108 1101 1109 Substitution sub = new Substitution(_selectedAction.getAgent(), 1102 new Symbol( "SELF"));1110 new Symbol(Constants.SELF)); 1103 1111 1104 1112 Plan clonedPlan = (Plan) _selectedPlan.clone(); … … 1126 1134 } 1127 1135 } 1128 else if(!_selectedAction.getAgent().toString().equals( "SELF"))1136 else if(!_selectedAction.getAgent().toString().equals(Constants.SELF)) 1129 1137 { 1130 1138 //we have to wait for another agent to act … … 1160 1168 } 1161 1169 1162 e = new Event( "SELF",action,target);1170 e = new Event(Constants.SELF,action,target); 1163 1171 _actionMonitor = new ActionMonitor(_selectedAction,e); 1164 1172 … … 1237 1245 public void update(AgentModel am, long time) 1238 1246 { 1239 if(_actionMonitor != null && _actionMonitor.Expired()) { 1240 AgentLogger.GetInstance().logAndPrint("Action monitor expired: " + _actionMonitor.toString()); 1241 //If the action expired we must check the plan links (continuous planning) 1242 //just to make sure 1243 CheckLinks(am); 1244 1245 1246 //System.out.println("Calling UpdateCertainty (action monitor expired)"); 1247 for(IActionFailureStrategy s : _actionFailureStrategies) 1248 { 1249 s.perceiveActionFailure(am, _actionMonitor.GetStep()); 1250 } 1251 _actionMonitor.GetStep().DecreaseProbability(am); 1252 1253 UpdateProbabilities(); 1254 _actionMonitor = null; 1247 if(_actionMonitor != null) 1248 { 1249 if(_actionMonitor.expired() || !_actionMonitor.checkPreconditions(am)) 1250 { 1251 AgentLogger.GetInstance().logAndPrint("Action monitor failed or expired: " + _actionMonitor.toString()); 1252 //If the action expired or failed we must check the plan links (continuous planning) 1253 //just to make sure 1254 CheckLinks(am); 1255 1256 for(IActionFailureStrategy s : _actionFailureStrategies) 1257 { 1258 s.perceiveActionFailure(am, _actionMonitor.getStep()); 1259 } 1260 _actionMonitor.getStep().DecreaseProbability(am); 1261 1262 UpdateProbabilities(); 1263 1264 cancelAction(am); 1265 _actionMonitor = null; 1266 } 1255 1267 } 1256 1268 } -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/deliberativeLayer/ExpirableActionMonitor.java
r667 r926 70 70 * @return true if the Monitor waited more than specified, false otherwise 71 71 */ 72 public boolean Expired() {72 public boolean expired() { 73 73 return AgentSimulationTime.GetInstance().Time() > _endTime; 74 74 } -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/reactiveLayer/ReactiveProcess.java
r896 r926 65 65 66 66 import FAtiMA.Core.AgentModel; 67 import FAtiMA.Core.IAppraisalDerivationComponent;68 import FAtiMA.Core.IBehaviourComponent;69 import FAtiMA.Core.IComponent;70 import FAtiMA.Core.IModelOfOtherComponent;71 67 import FAtiMA.Core.ValuedAction; 72 68 import FAtiMA.Core.Display.AgentDisplayPanel; 73 69 import FAtiMA.Core.OCCAffectDerivation.OCCAppraisalVariables; 74 70 import FAtiMA.Core.OCCAffectDerivation.OCCComponent; 71 import FAtiMA.Core.componentTypes.IAppraisalDerivationComponent; 72 import FAtiMA.Core.componentTypes.IBehaviourComponent; 73 import FAtiMA.Core.componentTypes.IComponent; 74 import FAtiMA.Core.componentTypes.IModelOfOtherComponent; 75 75 import FAtiMA.Core.emotionalState.AppraisalFrame; 76 76 import FAtiMA.Core.sensorEffector.Event; -
AgentMind/branches/FAtiMA-Modular/FAtiMA/src/FAtiMA/Core/sensorEffector/RemoteAgent.java
r911 r926 89 89 import FAtiMA.Core.AgentModel; 90 90 import FAtiMA.Core.AgentSimulationTime; 91 import FAtiMA.Core.IComponent;92 import FAtiMA.Core.IProcessExternalRequestComponent;93 91 import FAtiMA.Core.ValuedAction; 92 import FAtiMA.Core.componentTypes.IComponent; 93 import FAtiMA.Core.componentTypes.IProcessExternalRequestComponent; 94 94 import FAtiMA.Core.emotionalState.EmotionalState; 95 95 import FAtiMA.Core.util.AgentLogger;
Note: See TracChangeset
for help on using the changeset viewer.