From 72b40aec2addc7b28170ba9364bc0429149b3299 Mon Sep 17 00:00:00 2001 From: majortom6 Date: Sun, 26 Feb 2017 07:07:11 -0600 Subject: -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 --- inc/functions.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'inc/functions.hpp') 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 #include #include "rectangle.hpp" @@ -17,4 +18,11 @@ static float getRandom(float x){ return (-x + static_cast (rand()) / (static_cast (RAND_MAX/(x-(-x))))); } +static bool roll(float x){ + float y = (float)(rand()%101)/100; + if(x >= y) + return true; + else + return false; +} #endif -- cgit v1.2.3