Commit c04e5340 authored by fstuehlinger's avatar fstuehlinger
Browse files

corrections applied

parent f3ae0caf
#include <vector>
#include <bitset>
class Genome {
......@@ -13,14 +15,9 @@ public:
void setMutRate(unsigned int M_new);
static unsigned int N; // Number of genes (size of gen[])
static unsigned int M; // Mutation rate
// kszenes: Why is this an array of size 0? Arrays are static,
// meaning that you wont be able to change the size of gen. Use something
// like std::vector for dynamic arrays.
// Check out the solution where we use bitset which is more memory efficient
// than bool since sizeof(bool) = 1 byte = 4 bits
bool gen[0]; // Genome
static unsigned int N_; // Number of genes (size of gen[])
static unsigned int M_; // Mutation rate
std::bitset<100> gen_; // Genome
class Animal {
......@@ -30,7 +27,7 @@ public:
// Copy constructor:
Animal(const Animal& other);
// Constructing from genome (birth):
Animal(Genome g);
Animal(const Genome& g);
// Get current Age:
unsigned int getAge() const;
// Check wether animal is alive:
......@@ -51,12 +48,12 @@ public:
void setBirthRate(unsigned int birthRate_new);
static unsigned int T; // Threshold
static unsigned int repAge; // Reproduction age
static unsigned int birthRate; // Birth rate
unsigned int age; // Age
Genome gen; // Genome
bool preg; // Pregnancy
static unsigned int T_; // Threshold
static unsigned int repAge_; // Reproduction age
static unsigned int birthRate_; // Birth rate
unsigned int age_; // Age
Genome gen_; // Genome
bool preg_; // Pregnancy
class Population {
......@@ -77,7 +74,6 @@ public:
void iterateAnimals(void (*funcPtr)());
//kszenes: Again maybe dynamic array: std::vector<Animal>?
Animal pop[0];
static unsigned int N_max;
std::vector<Animal> pop_;
static unsigned int N_max_;
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment