diff options
author | tom <tombarrett@siu.edu> | 2017-02-12 08:42:55 -0600 |
---|---|---|
committer | tom <tombarrett@siu.edu> | 2017-02-12 08:42:55 -0600 |
commit | 60bc5dcb19a983e8ae335ba89f860c59473303fb (patch) | |
tree | 6f232f9db0d71678ce593a765b88f4934976ed83 /src/dna.cpp | |
parent | 1da46794f74ebd8f445fcd70cbe0420eadb648e4 (diff) |
-added DNA combining, currently it just takes the average of the mother and father
-there maybe a random segfault, further investigation is needed
Diffstat (limited to 'src/dna.cpp')
-rw-r--r-- | src/dna.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/dna.cpp b/src/dna.cpp index 36eda3d..1145276 100644 --- a/src/dna.cpp +++ b/src/dna.cpp @@ -12,3 +12,20 @@ Dna::Dna() expectedAge = CREATURE_EXP_AGE; sizeMax = CREATURE_SIZE_MAX; } + +Dna Dna::combine(Dna D) +{ + Dna N; + + N.maxHealth = (this->maxHealth + D.maxHealth)/2; + N.speed = (this->speed + D.speed)/2; + N.reach = (this->reach + D.reach)/2; + N.bestSense = (this->bestSense + D.bestSense)/2; + N.bite = (this->bite + D.bite)/2; + N.amountToGrow = (this->amountToGrow + D.amountToGrow)/2; + N.expectedPregnancyTime = (this->expectedPregnancyTime + D.expectedPregnancyTime)/2; + N.expectedAge = (this->expectedAge + D.expectedAge)/2; + N.sizeMax = (this->sizeMax + D.sizeMax)/2; + + return N; +} |