diff options
author | majortom6 <tombarrett@siu.edu> | 2017-02-26 07:07:11 -0600 |
---|---|---|
committer | Tom Barrett <tombarrett@siu.edu> | 2017-03-07 13:23:42 -0600 |
commit | 72b40aec2addc7b28170ba9364bc0429149b3299 (patch) | |
tree | c84358c619784a418adb4d0d71c6e91ccddc7f89 /inc | |
parent | c6d10c3d73e99043a29897eecf59656a18db989d (diff) |
-added more detailed mutation function, eventually a normal distrobution will be implemented
-added roll function, which takes a float ie (.15) and returns a true that percent of the time
Diffstat (limited to 'inc')
-rw-r--r-- | inc/constants.hpp | 6 | ||||
-rw-r--r-- | inc/dna.hpp | 3 | ||||
-rw-r--r-- | inc/functions.hpp | 8 |
3 files changed, 15 insertions, 2 deletions
diff --git a/inc/constants.hpp b/inc/constants.hpp index 518f2ac..6cb2982 100644 --- a/inc/constants.hpp +++ b/inc/constants.hpp @@ -22,6 +22,8 @@ const int CREATURE_EXP_PREG_TIME = 100; const int CREATURE_EXP_AGE = 1000000; const int CREATURE_SIZE_MAX = 10; const float CREATURE_SPEED = .1; +const float CREATURE_MUTATION_PERCENT = .25; +const float CREATURE_MUTATION_CHANCE = .05; // Resource const int RESOURCE_SIZE_START = 1; @@ -37,8 +39,8 @@ const float CREATURE_SIDES = 4.0; const float RESOURCE_SIDES = 10; // Quadtree -const int MAX_OBJECTS = 5; -const int MAX_LEVELS = 6; +const int MAX_OBJECTS = 10; +const int MAX_LEVELS = 10; // Camera const float MOVE_AMOUNT = .2; diff --git a/inc/dna.hpp b/inc/dna.hpp index d7312f6..b549c27 100644 --- a/inc/dna.hpp +++ b/inc/dna.hpp @@ -2,6 +2,7 @@ #define dna_h #include "constants.hpp" +#include "functions.hpp" class DNA { @@ -20,6 +21,8 @@ class DNA int sizeMax; float speed; + float mutationPercent; + float mutationChance; }; #endif diff --git a/inc/functions.hpp b/inc/functions.hpp index b0ecb65..ef6d555 100644 --- a/inc/functions.hpp +++ b/inc/functions.hpp @@ -1,6 +1,7 @@ #ifndef functions_h #define functions_h +#include <cstdlib> #include <cmath> #include "rectangle.hpp" @@ -17,4 +18,11 @@ static float getRandom(float x){ return (-x + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX/(x-(-x))))); } +static bool roll(float x){ + float y = (float)(rand()%101)/100; + if(x >= y) + return true; + else + return false; +} #endif |