diff --git a/include/agent.h b/include/agent.h index be23dfaaa7169dc63900359c660e2453461f0d6e..04a7888edf5f1033507a342c1400caf0beb4cb8b 100644 --- a/include/agent.h +++ b/include/agent.h @@ -15,7 +15,7 @@ public: Agent(Simulator* sim,VEC3 startingPoint,std::vector goals); Agent(Simulator* sim, VEC3 startingPoint,std::vector goals,Dart d) ; ~Agent(); - void init(VEC3 startingPoint,std::vector goals,Dart d); + void init(Simulator * sim ,VEC3 startingPoint,std::vector goals,Dart d); void updatePosition(); diff --git a/src/agent.cpp b/src/agent.cpp index a2346df11e994e3844f3528dcb093a21eca5e26f..7730442509fdb7b77a216c77371699eaf6470bce 100644 --- a/src/agent.cpp +++ b/src/agent.cpp @@ -1,8 +1,9 @@ #include "simulator.h" // initialisation Agent -void Agent::init(VEC3 startingPoint,std::vector goals,Dart d) +void Agent::init(Simulator * sim ,VEC3 startingPoint,std::vector goals,Dart d) { + sim_=sim; goals_=goals; r=0.0f; g=0.0f; @@ -16,21 +17,19 @@ void Agent::init(VEC3 startingPoint,std::vector goals,Dart d) maxVelocity_=3.0f; //lien simulateur agentNo=sim_->agents.size() ; - Simulator* sim_; + alive=true; sim_->agents.push_back(this); } -Agent::Agent(Simulator* sim,VEC3 startingPoint,std::vector goals, Dart d): - sim_(sim) +Agent::Agent(Simulator* sim,VEC3 startingPoint,std::vector goals, Dart d) { - init(startingPoint,goals,d); + init(sim,startingPoint,goals,d); } -Agent::Agent(Simulator* sim,VEC3 startingPoint,std::vector goals): - sim_(sim) +Agent::Agent(Simulator* sim,VEC3 startingPoint,std::vector goals) { - Dart d=sim_->envMap_.getBelongingCell(startingPoint); - init(startingPoint,goals,d); + Dart d=sim->envMap_.getBelongingCell(startingPoint); + init(sim,startingPoint,goals,d); } void Agent::updatePosition() diff --git a/src/simulator.cpp b/src/simulator.cpp index aa0039f9e28d438ce671dd09355d1f02374b36c2..d19b707a6edb060c85f8375046e1b3beba71ec67 100644 --- a/src/simulator.cpp +++ b/src/simulator.cpp @@ -84,6 +84,7 @@ void Simulator::initAgents(int nbAgents) goals.push_back(goal); goals.push_back(start); Agent * ag = new Agent(this,start,goals); + CGoGNout<<"agent initialisé : "<agentNo<agentNo << " : "<< agents_[i]<