Skip to content
Snippets Groups Projects
Commit 4c7a655e authored by fuzzy_bunny's avatar fuzzy_bunny
Browse files

Corrected captors and accessories choice code + enhanced step nb print msg

parent d4eae304
No related branches found
No related tags found
No related merge requests found
......@@ -22,10 +22,12 @@ Aquarium::Aquarium( int width, int height, int _delay, int startingNbOfAnimals,
string kamikazeName = (KamikazeBehaviour::getBehaviourInstance())->getBehaviourName();
// TODO : fixer la liste des availableCaptorsAndAccessories
Statistics* statistics = new Statistics({"b_multiple", gregariousName, fearfulName, kamikazeName, Fin::getName(), Eyes::getName()});
//Statistics* statistics = new Statistics({"b_multiple", gregariousName, fearfulName, kamikazeName, Fin::getName(), Eyes::getName()});
Statistics* statistics = new Statistics({"b_multiple", gregariousName, fearfulName, kamikazeName, "a_None"});
// TODO : fixer la liste des availableCaptorsAndAccessories
AnimalFactory* factory = new PetFactory(width, height, animalsDistribution, {Fin::getName(), Eyes::getName()}, *statistics);
//AnimalFactory* factory = new PetFactory(width, height, animalsDistribution, {Fin::getName(), Eyes::getName()}, *statistics);
AnimalFactory* factory = new PetFactory(width, height, animalsDistribution, {"a_None"} , *statistics);
water = new Environment(width, height, startingNbOfAnimals, *factory, *statistics);
......
......@@ -41,7 +41,7 @@ int Environment::getHeight() const {
void Environment::step() {
++nb_steps; // increment the number of steps
cout << "[" << nb_steps << "]" << endl;
cout << "[step #" << nb_steps << "]" << endl;
statistics.saveData(); // save statistics of the previous step before doing the new one
cimg_forXY(*this, x, y)
......
......@@ -5,7 +5,7 @@
#include "Eyes.h"
#include <iterator>
#include <random>
#include <stdlib.h>
using namespace std;
......@@ -22,10 +22,8 @@ string choose_unchosen_element(const unordered_set<string> remaining_elements) {
string chosen_one;
// randomly choosing an index in remaining_elements
default_random_engine random_generator;
uniform_int_distribution<int> distribution(0, remaining_elements.size()-1);
int index = distribution(random_generator);
int index = rand() % remaining_elements.size();
auto it = remaining_elements.begin();
for (int _i=0; _i<index; _i++){
it++;
......@@ -42,9 +40,7 @@ unordered_set<string> choose_elements(const unordered_set<string> available_elem
// randomly choosing a number of elements to choose
// this number is bound by the number of elements in available_elements
default_random_engine random_generator;
uniform_int_distribution<int> distribution(0,available_elements.size());
int nb_to_choose = distribution(random_generator);
int nb_to_choose = rand() % available_elements.size();
for (int i=0; i<nb_to_choose; i++){
string chosen_elem;
......@@ -76,7 +72,7 @@ Animal* PetFactory::createMember(string behaviour) {
pet->setBehaviourAsMultiple();
}
else{
if (behaviour != "none"){
if (behaviour != "a_None"){
pet->setBehaviour(behaviour);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment