-
Notifications
You must be signed in to change notification settings - Fork 0
/
Organism.h
93 lines (78 loc) · 2.05 KB
/
Organism.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* Organism.h
*
* Created on: Jul 31, 2011
* Author: Jeroen Vlek
* Email: [email protected]
* Website: www.perceptivebits.com
* License: Free Beer (Feel free to use it in every
* way possible and if you like it, make
* sure to give me credit and buy me a drink
* if we ever meet ;) )
*/
#ifndef ORGANISM_H_
#define ORGANISM_H_
#include <vector>
#include "Exceptions.h"
#include "Factory.h"
#include "Gene.h"
#include "PhenotypeImage.h"
#include "memory/PoolableObject.h"
/**
* The class that represents the organism. It contains both the genotype and
* phenotype.
*/
class Organism : public memory::PoolableObject<Organism>
{
public:
/**
* Constructs a DNA with length genomeLength.
*
* @param genomeLength The length of the gene sequence.
* @return DNA
*/
Organism(const unsigned int genomeLength = 0);
/**
* Constructs a DNA object by concatenating the genes from parent A with the
* genes from parent B.
*
* @param genesParentA Half of the genes of parent A
* @param genesParentB Half of the genes of parent B
* @return DNA
*/
Organism(const Organism& parentA, const Organism& parentB, const bool doMutation = false);
/**
* Destructor
*
* @return void
*/
virtual ~Organism();
/**
* Draws the phenotype image, bases on the genome and returns a reference to it.
*
* @return PhenotypeImage of this Organism
*/
PhenotypeImage& getPhenotype();
static bool compareScores(const Organism* a, const Organism* b);
inline double getScore() const { return m_score; }
inline void setScore(double score) { m_score = score; }
private:
/**
* The sequence of genes.
*/
std::vector<Gene> m_genome;
/**
* The score of this organism compared to the 'environment' (lower is better)
*/
double m_score;
/**
* The phenotype image that is derived from the genes. This derivation is done
* in the getPhenotype function.
*/
PhenotypeImage m_phenotype;
/**
* Creates the phenotype image from the genome
*/
void createPhenotype();
};
#endif /* ORGANISM_H_ */