Skip to content
Snippets Groups Projects

Aymeric

Merged BERTHOUMIEU Aymeric requested to merge Aymeric into master
1 file
+ 19
19
Compare changes
  • Side-by-side
  • Inline
+ 19
19
@@ -83,29 +83,29 @@ std::vector<Animal *> Environment::detectedNeighbors(Animal* a){
void Environment::die() {
// kill animal in the ecosystem at the end of the step
// first we identify the animals to remove (if any)
std::vector<Animal*>::iterator it = std::remove_if(animals.begin(), animals.end(), mustDie);
// then we update Statistics
for (std::vector<Animal*>::iterator iter = it; iter != animals.end(); ++iter) {
// first we update Statistics
for (std::vector<Animal*>::iterator iter = animals.begin(); iter != animals.end(); ++iter) {
// All animal at the end of the vector at this step are going to die
// Behaviours
if ((*iter)->getIsMultiple()) {
cout << "In Environment::die(), isMultiple= " << (*iter)->getIsMultiple() << endl;
statistics.modifyData(multiple, false);
} else {
cout << "In Environment::die(), not multiple so = " << (*iter)->getBehaviourName() << endl;
std::string behaviour = (*iter)->getBehaviourName();
statistics.modifyData(behaviour, false);
if ((*iter)->getLife() <= 0){
if ((*iter)->getIsMultiple()) {
statistics.modifyData(multiple, false);
} else {
std::string behaviour = (*iter)->getBehaviourName();
statistics.modifyData(behaviour, false);
}
// Captors and accessories
// TODO: decrement accessories and captors
/*std::vector <std::string> acc = (*iter)->getAccessoriesAndCaptors();
for (std::string element : acc) {
statistics.modifyData(element, false);
}*/
}
// Captors and accessories
// TODO: decrement accessories and captors
/*std::vector <std::string> acc = (*iter)->getAccessoriesAndCaptors();
for (std::string element : acc) {
statistics.modifyData(element, false);
}*/
}
// then we identify the animals to remove (if any)
std::vector<Animal*>::iterator it = std::remove_if(animals.begin(), animals.end(), mustDie);
// Finally, we delete the relevant animals
animals.erase(it, animals.end());
}
Loading