#include <sensors_motivations_actions_def.h>
Public Member Functions | |
CActionResources () | |
void | filterMyActions (std::multimap< double, std::pair< TTargetId, TAction > > &myActionsByPriority) |
Let in the map myActionsByPriority all actions with no more actions Resources (thoses actions shouldn't be executed). | |
virtual | ~CActionResources () |
Private Attributes | |
std::multimap< TAction, TActionResources > | _ActionsResources |
|
Definition at line 31 of file sensors_motivations_actions_def.cpp. References _ActionsResources, NLAINIMAT::Action_LookAround, NLAINIMAT::Action_MoveToMyFlagGoal, NLAINIMAT::Action_MoveToMyFlagStart, NLAINIMAT::Action_MoveToTargetFlag, NLAINIMAT::Action_MoveToTargetFlagGoal, NLAINIMAT::Action_MoveToTargetFlagStart, NLAINIMAT::Action_SelectClassDemoman, NLAINIMAT::Action_SelectClassEngineer, NLAINIMAT::Action_SelectClassHwguy, NLAINIMAT::Action_SelectClassMedic, NLAINIMAT::Action_SelectClassPyro, NLAINIMAT::Action_SelectClassScout, NLAINIMAT::Action_SelectClassSniper, NLAINIMAT::Action_SelectClassSoldier, NLAINIMAT::Action_SelectClassSpy, NLAINIMAT::Action_Target_Approach, NLAINIMAT::Action_Target_MoveAway, NLAINIMAT::Action_Target_ShootTo, NLAINIMAT::ActionResources_button_attack, NLAINIMAT::ActionResources_button_attack2, NLAINIMAT::ActionResources_button_jump, NLAINIMAT::ActionResources_forwardMove, NLAINIMAT::ActionResources_pitch, NLAINIMAT::ActionResources_selectClass, and NLAINIMAT::ActionResources_yaw.
00032 { 00033 // _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_Idle, ActionResources_forwardMove)); 00034 00035 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_Target_MoveAway, ActionResources_forwardMove)); 00036 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_Target_MoveAway, ActionResources_yaw)); 00037 00038 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_Target_ShootTo, ActionResources_pitch)); 00039 // _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_Target_ShootTo, ActionResources_yaw)); 00040 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_Target_ShootTo, ActionResources_button_attack)); 00041 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_Target_ShootTo, ActionResources_button_attack2)); 00042 00043 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_Target_Approach, ActionResources_forwardMove)); 00044 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_Target_Approach, ActionResources_yaw)); 00045 00046 // _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_Item_Approach, ActionResources_forwardMove)); 00047 // _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_Item_Approach, ActionResources_yaw)); 00048 00049 // _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_Waypoint_MoveTo, ActionResources_forwardMove)); 00050 // _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_Waypoint_MoveTo, ActionResources_yaw)); 00051 // _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_Waypoint_MoveTo, ActionResources_button_jump)); 00052 00053 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_MoveToTargetFlag, ActionResources_forwardMove)); 00054 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_MoveToTargetFlag, ActionResources_yaw)); 00055 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_MoveToTargetFlag, ActionResources_button_jump)); 00056 00057 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_MoveToTargetFlagStart, ActionResources_forwardMove)); 00058 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_MoveToTargetFlagStart, ActionResources_yaw)); 00059 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_MoveToTargetFlagStart, ActionResources_button_jump)); 00060 00061 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_MoveToTargetFlagGoal, ActionResources_forwardMove)); 00062 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_MoveToTargetFlagGoal, ActionResources_yaw)); 00063 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_MoveToTargetFlagGoal, ActionResources_button_jump)); 00064 00065 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_MoveToMyFlagStart, ActionResources_forwardMove)); 00066 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_MoveToMyFlagStart, ActionResources_yaw)); 00067 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_MoveToMyFlagStart, ActionResources_button_jump)); 00068 00069 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_MoveToMyFlagGoal, ActionResources_forwardMove)); 00070 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_MoveToMyFlagGoal, ActionResources_yaw)); 00071 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_MoveToMyFlagGoal, ActionResources_button_jump)); 00072 00073 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_LookAround, ActionResources_forwardMove)); 00074 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_LookAround, ActionResources_yaw)); 00075 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_LookAround, ActionResources_button_jump)); 00076 00077 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_SelectClassScout, ActionResources_selectClass)); 00078 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_SelectClassSniper, ActionResources_selectClass)); 00079 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_SelectClassSoldier, ActionResources_selectClass)); 00080 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_SelectClassDemoman, ActionResources_selectClass)); 00081 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_SelectClassMedic, ActionResources_selectClass)); 00082 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_SelectClassHwguy, ActionResources_selectClass)); 00083 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_SelectClassPyro, ActionResources_selectClass)); 00084 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_SelectClassSpy, ActionResources_selectClass)); 00085 _ActionsResources.insert(std::pair<TAction, TActionResources>(Action_SelectClassEngineer, ActionResources_selectClass)); 00086 } |
|
Definition at line 88 of file sensors_motivations_actions_def.cpp.
00089 { 00090 ; 00091 } |
|
Let in the map myActionsByPriority all actions with no more actions Resources (thoses actions shouldn't be executed).
Definition at line 94 of file sensors_motivations_actions_def.cpp. References _ActionsResources, NLAINIMAT::TAction, and NLAINIMAT::TActionResources. Referenced by NLAINIMAT::CMHiCSagent::selectBehavior().
00095 { 00096 // We build a set of used resources. 00097 std::set<TActionResources> usedActionsResources; 00098 00099 // For each wanted action in from the highest priority to the lowest 00100 std::multimap<double, std::pair<TTargetId,TAction> >::reverse_iterator itMyActionsByPriority( myActionsByPriority.end()); 00101 std::multimap<double, std::pair<TTargetId,TAction> >::reverse_iterator itLast(myActionsByPriority.begin()); 00102 std::set<TActionResources>::iterator itUsedActionsResources; 00103 std::multimap<TAction, TActionResources>::iterator itActionsResources, itActionsResources_begin, itActionsResources_last; 00104 bool actionIsOK = false; 00105 std::multimap<double, std::pair<TTargetId,TAction> >::iterator itMyActionsByPriority2Remove; 00106 00107 while (itMyActionsByPriority != itLast ) 00108 { 00109 double priority = (*itMyActionsByPriority).first; 00110 TAction action = (*itMyActionsByPriority).second.second; 00111 itMyActionsByPriority++; 00112 00113 // if none of the resources are used, the action may be executed and resources are stored as used. 00114 if (actionIsOK) 00115 { 00116 for (itActionsResources = itActionsResources_begin; 00117 itActionsResources != itActionsResources_last; 00118 itActionsResources++) 00119 { 00120 TActionResources ar = (*itActionsResources).second; 00121 usedActionsResources.insert(ar); 00122 } 00123 myActionsByPriority.erase(itMyActionsByPriority2Remove); 00124 } 00125 00126 // We look for all needed action resources. 00127 itActionsResources_begin = _ActionsResources.lower_bound(action); 00128 itActionsResources_last = _ActionsResources.upper_bound(action); 00129 actionIsOK = true; 00130 00131 // For each of thoses resources we look if it's already used. 00132 for (itActionsResources = itActionsResources_begin; 00133 itActionsResources != itActionsResources_last; 00134 itActionsResources++) 00135 { 00136 TActionResources ar = (*itActionsResources).second; 00137 itUsedActionsResources = usedActionsResources.find(ar); 00138 if( itUsedActionsResources != usedActionsResources.end()) 00139 { 00140 actionIsOK = false; 00141 break; 00142 } 00143 } 00144 00145 itMyActionsByPriority2Remove = itMyActionsByPriority.base(); 00146 } 00147 00148 if (actionIsOK) 00149 { 00150 for (itActionsResources = itActionsResources_begin; 00151 itActionsResources != itActionsResources_last; 00152 itActionsResources++) 00153 { 00154 TActionResources ar = (*itActionsResources).second; 00155 usedActionsResources.insert(ar); 00156 } 00157 myActionsByPriority.erase(itMyActionsByPriority2Remove); 00158 } 00159 } |
|
Definition at line 296 of file sensors_motivations_actions_def.h. Referenced by CActionResources(), and filterMyActions(). |