diff options
author | majortom6 <tombarrett@siu.edu> | 2017-02-26 11:24:11 -0600 |
---|---|---|
committer | Tom Barrett <tombarrett@siu.edu> | 2017-03-07 13:23:42 -0600 |
commit | 97da09996e9c2aaa6f524879a15fbab4b1d01dec (patch) | |
tree | 949f69801db02257f781303d333d836fd9462d0b | |
parent | 7394b069537ed7a490a343381d62862eb22abdcf (diff) |
minor reordering
-rw-r--r-- | inc/list.hpp | 4 | ||||
-rw-r--r-- | src/dna.cpp | 26 |
2 files changed, 16 insertions, 14 deletions
diff --git a/inc/list.hpp b/inc/list.hpp index 93a0537..5f1ba8e 100644 --- a/inc/list.hpp +++ b/inc/list.hpp @@ -12,8 +12,8 @@ class List { public: List(); - void Behavior(); - void Place(); + void Behavior(); + void Place(); void Remove(); std::vector<Organism*> getNear(Organism o); diff --git a/src/dna.cpp b/src/dna.cpp index 5d727d2..6968c90 100644 --- a/src/dna.cpp +++ b/src/dna.cpp @@ -32,15 +32,16 @@ DNA::DNA(std::string s) DNA DNA::combine(DNA D) { - DNA N("empty"); + DNA N; N.type = CREATURE_TYPE; N.maxHealth = (maxHealth + D.maxHealth)/2; - N.speed = (speed + D.speed)/2; - N.reach = (reach + D.reach)/2; N.bestSense = (bestSense + D.bestSense)/2; N.bite = (bite + D.bite)/2; N.expectedPregnancyTime = (expectedPregnancyTime + D.expectedPregnancyTime)/2; N.expectedAge = (expectedAge + D.expectedAge)/2; + N.growAmount = (growAmount + D.growAmount)/2 + N.reach = (reach + D.reach)/2; + N.speed = (speed + D.speed)/2; N.mutationPercent = (mutationPercent + D.mutationPercent)/2; N.mutationChance = (mutationChance + D.mutationChance)/2; @@ -50,16 +51,17 @@ DNA DNA::combine(DNA D) pn = 1; else pn = -1; - switch(rand()%9){ + switch(rand()%10){ case 0: N.maxHealth = abs(N.maxHealth *(N.mutationPercent+pn)); break; - case 1: N.speed = abs(N.speed *(N.mutationPercent+pn)); break; - case 2: N.reach = abs(N.reach *(N.mutationPercent+pn)); break; - case 3: N.bestSense = abs(N.bestSense *(N.mutationPercent+pn)); break; - case 4: N.bite = abs(N.bite *(N.mutationPercent+pn)); break; - case 5: N.expectedPregnancyTime = abs(N.expectedPregnancyTime *(N.mutationPercent+pn)); break; - case 6: N.expectedAge = abs(N.expectedAge *(N.mutationPercent+pn)); break; - case 7: N.mutationPercent = abs(N.expectedAge *(N.mutationPercent+pn)); break; - case 8: N.mutationChance = abs(N.mutationChance *(N.mutationPercent+pn)); break; + case 1: N.bestSense = abs(N.bestSense *(N.mutationPercent+pn)); break; + case 2: N.bite = abs(N.bite *(N.mutationPercent+pn)); break; + case 3: N.expectedPregnancyTime = abs(N.expectedPregnancyTime *(N.mutationPercent+pn)); break; + case 4: N.expectedAge = abs(N.expectedAge *(N.mutationPercent+pn)); break; + case 5: N.growAmount = abs(N.growAmount *(N.mutationPercent+pn)); break; + case 6: N.reach = abs(N.reach *(N.mutationPercent+pn)); break; + case 7: N.speed = abs(N.speed *(N.mutationPercent+pn)); break; + case 8: N.mutationPercent = abs(N.expectedAge *(N.mutationPercent+pn)); break; + case 9: N.mutationChance = abs(N.mutationChance *(N.mutationPercent+pn)); break; } } return N; |