Skip to content
Snippets Groups Projects
Commit 7adfc4dc authored by Aymeric berthoumieu's avatar Aymeric berthoumieu
Browse files

statistics integrated

parent dda60657
No related branches found
No related tags found
1 merge request!20Aymeric
......@@ -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());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment