summaryrefslogtreecommitdiff
path: root/src/dna.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dna.cpp')
-rw-r--r--src/dna.cpp17
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;
+}