00001 #ifndef AGENT_H__ 00002 #define AGENT_H__ 00003 00004 #ifdef DARWIN 00005 #include <Python/Python.h> 00006 #else 00007 #include <Python.h> 00008 #endif 00009 00010 #include <ngl/Vec3.h> 00011 #include <ngl/TransformStack.h> 00012 #include <ngl/Camera.h> 00013 #include <string> 00014 #include "Brain.h" 00015 #include "Environment.h" 00016 #include "Models.h" 00017 #include "Ammo.h" 00018 #include <stack> 00019 #include <queue> 00020 #include "AIagent.h" 00021 #include "UserAgent.h" 00022 #include "Army.h" 00023 00024 00033 00034 enum Player{red,blue,ball}; 00035 00036 class Environment; 00037 class Brain; 00038 class Ammo; 00039 class Graph; 00040 class GraphEdge; 00041 class AIagent; 00042 class UserAgent; 00043 class Army; 00044 00045 00046 class Agent 00047 { 00048 public : 00049 //---------------------------------------------------------------------------------------------------------------------- 00055 //---------------------------------------------------------------------------------------------------------------------- 00056 Agent(Environment *_environment,Models *_model,Graph *_graph); 00057 //---------------------------------------------------------------------------------------------------------------------- 00059 //---------------------------------------------------------------------------------------------------------------------- 00060 ~Agent(); 00061 //---------------------------------------------------------------------------------------------------------------------- 00063 //---------------------------------------------------------------------------------------------------------------------- 00064 void update(); 00065 //---------------------------------------------------------------------------------------------------------------------- 00069 //---------------------------------------------------------------------------------------------------------------------- 00070 void draw( 00071 ngl::TransformStack *_tx, 00072 ngl::Camera *_cam 00073 ); 00074 //---------------------------------------------------------------------------------------------------------------------- 00077 //---------------------------------------------------------------------------------------------------------------------- 00078 float inline getScore(); 00079 //---------------------------------------------------------------------------------------------------------------------- 00082 //---------------------------------------------------------------------------------------------------------------------- 00083 void inline setScore(const int _score); 00084 //---------------------------------------------------------------------------------------------------------------------- 00086 //---------------------------------------------------------------------------------------------------------------- 00087 void inline resetScore(); 00088 00089 int inline getReset(); 00090 //---------------------------------------------------------------------------------------------------------------------- 00093 //---------------------------------------------------------------------------------------------------------------- 00094 int getPrecision(); 00095 //---------------------------------------------------------------------------------------------------------------------- 00096 ngl::Vec3 getAITargetPos(int _ID); 00097 //---------------------------------------------------------------------------------------------------------------------- 00101 //---------------------------------------------------------------------------------------------------------------------- 00102 void setAITargetPos(const ngl::Vec3 _pos,const int _ID); 00103 //---------------------------------------------------------------------------------------------------------------------- 00106 //---------------------------------------------------------------------------------------------------------------------- 00107 void setAITargetPos(const ngl::Vec3 _pos); 00108 //---------------------------------------------------------------------------------------------------------------------- 00110 //---------------------------------------------------------------------------------------------------------------------- 00111 ngl::Vec3 getUserPosition(std::string _name); 00112 //---------------------------------------------------------------------------------------------------------------------- 00116 //---------------------------------------------------------------------------------------------------------------------- 00117 void addNewArmy(PyObject *_main, PyObject *_dict); 00118 //---------------------------------------------------------------------------------------------------------------------- 00131 //---------------------------------------------------------------------------------------------------------------------- 00132 void addAIagent(std::string _file, PyObject *_main, PyObject *_dict, int _index,std::string _meshName, float _radius, std::string _type, int _id, int _armyId,std::string _state); 00133 //---------------------------------------------------------------------------------------------------------------------- 00143 //---------------------------------------------------------------------------------------------------------------------- 00144 void addAIagent(std::string _file,PyObject *_main,PyObject *_dict,ngl::Vec3 _pos, std::string _type,float _radius,std::string _meshName,int _ID); 00145 //---------------------------------------------------------------------------------------------------------------------- 00150 //---------------------------------------------------------------------------------------------------------------------- 00151 void addUserAgent(int _index, std::string _meshName,std::string _name); 00152 //---------------------------------------------------------------------------------------------------------------------- 00155 //---------------------------------------------------------------------------------------------------------------------- 00156 AIagent* getAIagent(int _id); 00157 //---------------------------------------------------------------------------------------------------------------------- 00160 //---------------------------------------------------------------------------------------------------------------------- 00161 UserAgent* getUserAgent(std::string _name); 00162 //---------------------------------------------------------------------------------------------------------------------- 00165 //---------------------------------------------------------------------------------------------------------------------- 00166 void addPongPlayers(PyObject *_main, PyObject *_dict); 00167 //---------------------------------------------------------------------------------------------------------------------- 00169 //---------------------------------------------------------------------------------------------------------------------- 00170 void clearAgents(); 00171 //---------------------------------------------------------------------------------------------------------------------- 00173 //---------------------------------------------------------------------------------------------------------------------- 00174 void resetAgents(); 00175 //---------------------------------------------------------------------------------------------------------------------- 00177 //---------------------------------------------------------------------------------------------------------------------- 00178 void setInitialOccupiedStatus(); 00179 //---------------------------------------------------------------------------------------------------------------------- 00183 //---------------------------------------------------------------------------------------------------------------------- 00184 void addPongPlayers(PyObject *_main, PyObject *_dict,ngl::Vec3 _pos1,ngl::Vec3 _pos2); 00185 //---------------------------------------------------------------------------------------------------------------------- 00187 //---------------------------------------------------------------------------------------------------------------------- 00188 void agentsQueryUpdate(AIagent* _agent); 00189 //---------------------------------------------------------------------------------------------------------------------- 00191 //---------------------------------------------------------------------------------------------------------------------- 00192 void checkUserBulletsCollision(std::list <Ammo *> _bullets); 00193 //---------------------------------------------------------------------------------------------------------------------- 00195 //---------------------------------------------------------------------------------------------------------------------- 00196 void checKTheAIhitstatus(Ammo* _ammo); 00197 //---------------------------------------------------------------------------------------------------------------------- 00199 //---------------------------------------------------------------------------------------------------------------------- 00200 inline std::list <AIagent* > getAIagentsList(){return m_aiAgents;} 00201 00202 00203 private : 00204 00205 00206 //---------------------------------------------------------------------------------------------------------------------- 00208 //---------------------------------------------------------------------------------------------------------------------- 00209 PyObject *m_main; 00210 //---------------------------------------------------------------------------------------------------------------------- 00212 //---------------------------------------------------------------------------------------------------------------------- 00213 PyObject *m_dict; 00214 //---------------------------------------------------------------------------------------------------------------------- 00216 //---------------------------------------------------------------------------------------------------------------------- 00217 Environment *m_environment; 00218 //---------------------------------------------------------------------------------------------------------------------- 00220 //---------------------------------------------------------------------------------------------------------------------- 00221 Models *m_model; 00222 //---------------------------------------------------------------------------------------------------------------------- 00224 //---------------------------------------------------------------------------------------------------------------------- 00225 Graph *m_graph; 00226 //---------------------------------------------------------------------------------------------------------------------- 00228 //---------------------------------------------------------------------------------------------------------------------- 00229 int m_precision; 00230 //---------------------------------------------------------------------------------------------------------------------- 00232 //---------------------------------------------------------------------------------------------------------------------- 00233 std::list <AIagent *> m_aiAgents; 00234 //---------------------------------------------------------------------------------------------------------------------- 00236 //---------------------------------------------------------------------------------------------------------------------- 00237 std::list <AIagent *> m_aiAgentsTempVector; 00238 //---------------------------------------------------------------------------------------------------------------------- 00240 //---------------------------------------------------------------------------------------------------------------------- 00241 std::list <UserAgent *> m_userAgent; 00242 //---------------------------------------------------------------------------------------------------------------------- 00244 //---------------------------------------------------------------------------------------------------------------------- 00245 std::map <int, AIagent *>m_aiAgentMap; 00246 //---------------------------------------------------------------------------------------------------------------------- 00248 //---------------------------------------------------------------------------------------------------------------------- 00249 std::map <std::string, UserAgent*> m_userAgentMap; 00250 //---------------------------------------------------------------------------------------------------------------------- 00252 //---------------------------------------------------------------------------------------------------------------------- 00253 std::list <Army* > m_armies; 00254 //---------------------------------------------------------------------------------------------------------------------- 00256 //---------------------------------------------------------------------------------------------------------------------- 00257 std::map <int , Army *>m_armyMap; 00258 //---------------------------------------------------------------------------------------------------------------------- 00260 //---------------------------------------------------------------------------------------------------------------------- 00261 int m_aiagentID; 00262 //---------------------------------------------------------------------------------------------------------------------- 00264 //---------------------------------------------------------------------------------------------------------------------- 00265 int m_armyID; 00266 00267 }; 00268 00269 00270 #endif 00271