00001 #ifndef BRAIN_H 00002 #define BRAIN_H 00003 00004 #ifdef DARWIN 00005 #include <Python/Python.h> 00006 #else 00007 #include <Python.h> 00008 #endif 00009 00010 #include <string> 00011 #include <ngl/Vec3.h> 00012 #include "Environment.h" 00013 #include "Agent.h" 00014 #include <boost/python.hpp> 00015 00024 00025 00026 using namespace boost::python; 00027 00028 00029 00030 class Environment; 00031 class AIagent; 00032 class Graph; 00033 class GraphEdge; 00034 class Brain 00035 { 00036 public: 00037 //---------------------------------------------------------------------------------------------------------------------- 00047 //---------------------------------------------------------------------------------------------------------------------- 00048 Brain(std::string *_script,PyObject *_main,PyObject *_dict, ngl::Vec3 &_pos,ngl::Vec3 &_vel, AIagent *_p, Graph* _graph); 00049 //---------------------------------------------------------------------------------------------------------------------- 00051 //---------------------------------------------------------------------------------------------------------------------- 00052 ~Brain(); 00053 //---------------------------------------------------------------------------------------------------------------------- 00056 //---------------------------------------------------------------------------------------------------------------------- 00057 void inline setScript(std::string *_script){m_script = _script;} 00058 //---------------------------------------------------------------------------------------------------------------------- 00060 //---------------------------------------------------------------------------------------------------------------------- 00061 ngl::Vec3 inline getPos(){return m_pos;} 00062 //---------------------------------------------------------------------------------------------------------------------- 00065 //---------------------------------------------------------------------------------------------------------------------- 00066 void inline setPos(const ngl::Vec3 _pos){m_pos = _pos;} 00067 //---------------------------------------------------------------------------------------------------------------------- 00070 //---------------------------------------------------------------------------------------------------------------------- 00071 void inline setVel(const ngl::Vec3 _vel){m_velocity = _vel;} 00072 //---------------------------------------------------------------------------------------------------------------------- 00074 //---------------------------------------------------------------------------------------------------------------------- 00075 ngl::Vec3 inline getVelocity(){return m_velocity;} 00076 //---------------------------------------------------------------------------------------------------------------------- 00078 //---------------------------------------------------------------------------------------------------------------------- 00079 ngl::Vec3 inline getForce(){return m_force;} 00080 //---------------------------------------------------------------------------------------------------------------------- 00082 //---------------------------------------------------------------------------------------------------------------------- 00083 void brainFunction(); 00084 //---------------------------------------------------------------------------------------------------------------------- 00086 //---------------------------------------------------------------------------------------------------------------------- 00087 void reset(); 00088 //---------------------------------------------------------------------------------------------------------------------- 00090 //---------------------------------------------------------------------------------------------------------------------- 00091 void setGraphdata(); 00092 00093 00094 00095 00096 00097 private: 00098 //---------------------------------------------------------------------------------------------------------------------- 00100 //---------------------------------------------------------------------------------------------------------------------- 00101 ngl::Vec3 m_pos; 00102 //---------------------------------------------------------------------------------------------------------------------- 00104 //---------------------------------------------------------------------------------------------------------------------- 00105 ngl::Vec3 m_dir; 00106 //---------------------------------------------------------------------------------------------------------------------- 00108 //---------------------------------------------------------------------------------------------------------------------- 00109 ngl::Vec3 m_velocity; 00110 //---------------------------------------------------------------------------------------------------------------------- 00112 //---------------------------------------------------------------------------------------------------------------------- 00113 ngl::Vec3 m_force; 00114 //---------------------------------------------------------------------------------------------------------------------- 00116 //---------------------------------------------------------------------------------------------------------------------- 00117 std::string *m_script; 00118 //---------------------------------------------------------------------------------------------------------------------- 00120 //---------------------------------------------------------------------------------------------------------------------- 00121 std::string m_filename; 00122 //---------------------------------------------------------------------------------------------------------------------- 00124 //---------------------------------------------------------------------------------------------------------------------- 00126 //---------------------------------------------------------------------------------------------------------------------- 00127 PyObject *m_main; 00128 //---------------------------------------------------------------------------------------------------------------------- 00130 //---------------------------------------------------------------------------------------------------------------------- 00131 PyObject *m_dict; 00132 //---------------------------------------------------------------------------------------------------------------------- 00134 //---------------------------------------------------------------------------------------------------------------------- 00135 PyObject *m_pyPos; 00136 //---------------------------------------------------------------------------------------------------------------------- 00138 //---------------------------------------------------------------------------------------------------------------------- 00139 PyObject *m_pyDir; 00140 //---------------------------------------------------------------------------------------------------------------------- 00142 //---------------------------------------------------------------------------------------------------------------------- 00143 PyObject *m_pySpeed; 00144 //---------------------------------------------------------------------------------------------------------------------- 00146 //---------------------------------------------------------------------------------------------------------------------- 00147 PyObject *m_pyForce; 00148 //---------------------------------------------------------------------------------------------------------------------- 00150 //---------------------------------------------------------------------------------------------------------------------- 00151 PyObject *m_pyGraph; 00152 //---------------------------------------------------------------------------------------------------------------------- 00154 //---------------------------------------------------------------------------------------------------------------------- 00155 PyObject *m_startScript; 00156 //---------------------------------------------------------------------------------------------------------------------- 00158 //---------------------------------------------------------------------------------------------------------------------- 00159 AIagent *m_parent; 00160 //---------------------------------------------------------------------------------------------------------------------- 00162 //---------------------------------------------------------------------------------------------------------------------- 00163 bool m_queryResponse; 00164 //---------------------------------------------------------------------------------------------------------------------- 00166 //---------------------------------------------------------------------------------------------------------------------- 00167 Graph* m_graph; 00168 //---------------------------------------------------------------------------------------------------------------------- 00170 //---------------------------------------------------------------------------------------------------------------------- 00171 PyObject* m_pyNodes; 00172 //---------------------------------------------------------------------------------------------------------------------- 00174 //---------------------------------------------------------------------------------------------------------------------- 00175 PyObject* m_pyNodePos; 00176 //---------------------------------------------------------------------------------------------------------------------- 00178 //---------------------------------------------------------------------------------------------------------------------- 00179 PyObject* m_pyNextNodePos; 00180 //---------------------------------------------------------------------------------------------------------------------- 00182 //---------------------------------------------------------------------------------------------------------------------- 00183 PyObject* m_pyEdgeData; 00184 //---------------------------------------------------------------------------------------------------------------------- 00186 //---------------------------------------------------------------------------------------------------------------------- 00187 PyObject* m_pyDirection; 00188 //---------------------------------------------------------------------------------------------------------------------- 00190 //---------------------------------------------------------------------------------------------------------------------- 00191 PyObject* m_pyMessage; 00192 //---------------------------------------------------------------------------------------------------------------------- 00194 //---------------------------------------------------------------------------------------------------------------------- 00195 PyObject* m_pyChase; 00196 //---------------------------------------------------------------------------------------------------------------------- 00198 //---------------------------------------------------------------------------------------------------------------------- 00199 PyObject* m_pyHome; 00200 //---------------------------------------------------------------------------------------------------------------------- 00202 //---------------------------------------------------------------------------------------------------------------------- 00203 PyObject* m_pyState; 00204 //---------------------------------------------------------------------------------------------------------------------- 00206 //---------------------------------------------------------------------------------------------------------------------- 00207 int m_index; 00208 //---------------------------------------------------------------------------------------------------------------------- 00210 //---------------------------------------------------------------------------------------------------------------------- 00211 int m_nextIndex; 00212 00213 }; 00214 00215 00216 #endif // BRAIN_H