diff options
author | majortom6 <tombarrett@siu.edu> | 2017-03-05 13:13:44 -0600 |
---|---|---|
committer | Tom Barrett <tombarrett@siu.edu> | 2017-03-07 13:23:42 -0600 |
commit | 8f5a73f1daba39c8b0175036cf688f8ce1399a8f (patch) | |
tree | 1bd365c1eb41d1b6f19ccac747919b2b762b72c0 /src/dna.cpp | |
parent | dfda3f2a5e555d3173359134f4994bcd12d129f8 (diff) |
-added carnivores
-removed creature type constant and replaced it with herbavore/carnivore type
-replaced resource type with plant type
-added eatType to dna (whatever the organism goes for hunger)
Diffstat (limited to 'src/dna.cpp')
-rw-r--r-- | src/dna.cpp | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/src/dna.cpp b/src/dna.cpp index ac2d500..4e22d7a 100644 --- a/src/dna.cpp +++ b/src/dna.cpp @@ -2,8 +2,9 @@ DNA::DNA(std::string s) { - if(s == "creature"){ - type = CREATURE_TYPE; + if(s == "herbavore"){ + type = HERBAVORE_TYPE; + eatType = PLANT_TYPE; maxHealth = CREATURE_MAX_HEALTH; bestSense = CREATURE_BEST_SENSE; bite = CREATURE_BITE; @@ -16,11 +17,30 @@ DNA::DNA(std::string s) mutationChance = CREATURE_MUTATION_CHANCE; appearance.sides = CREATURE_SIDES; appearance.red = 0; - appearance.green = 1; + appearance.green = 0.5; appearance.blue = 1; } - else if(s == "resource"){ - type = RESOURCE_TYPE; + else if(s == "carnivore"){ + type = CARNIVORE_TYPE; + eatType = HERBAVORE_TYPE; + maxHealth = CREATURE_MAX_HEALTH * 2; + bestSense = CREATURE_BEST_SENSE * 2; + bite = CREATURE_BITE * 2; + expectedPregnancyTime = CREATURE_EXP_PREG_TIME; + expectedAge = CREATURE_EXP_AGE * 2; + growAmount = 0; + reach = CREATURE_REACH * 2; + speed = CREATURE_SPEED * 2; + mutationPercent = CREATURE_MUTATION_PERCENT; + mutationChance = CREATURE_MUTATION_CHANCE; + appearance.sides = CREATURE_SIDES; + appearance.red = 1; + appearance.green = 0; + appearance.blue = 0; + } + else if(s == "plant"){ + type = PLANT_TYPE; + eatType = 0; maxHealth = RESOURCE_MAX_HEALTH; bestSense = 0; bite = 0; @@ -41,7 +61,8 @@ DNA::DNA(std::string s) DNA DNA::combine(DNA D) { DNA N; - N.type = CREATURE_TYPE; + N.type = type; + N.eatType = eatType; N.maxHealth = (maxHealth + D.maxHealth)/2; N.bestSense = (bestSense + D.bestSense)/2; N.bite = (bite + D.bite)/2; @@ -53,9 +74,9 @@ DNA DNA::combine(DNA D) N.mutationPercent = (mutationPercent + D.mutationPercent)/2; N.mutationChance = (mutationChance + D.mutationChance)/2; N.appearance.sides = CREATURE_SIDES; - N.appearance.red = 0; - N.appearance.green = 1; - N.appearance.blue = 1; + N.appearance.red = appearance.red; + N.appearance.green = appearance.green; + N.appearance.blue = appearance.blue; if(roll(mutationChance)){ float pn; |