diff options
author | rafa_99 <rafa99@protonmail.com> | 2020-12-04 01:34:14 +0000 |
---|---|---|
committer | rafa_99 <rafa99@protonmail.com> | 2020-12-04 01:34:14 +0000 |
commit | 650fb220913f79b5016dcfe1e497493619bf6fa2 (patch) | |
tree | 00ef5590e07b493940c8eeeec748666797a846d7 /utils.c | |
parent | 2e4fb93e33b92e5546c6d17a53743ac3cfb7e86b (diff) |
Found a good algorithm to randomize seeds
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -2,6 +2,7 @@ #include <unistd.h> #include <stdlib.h> #include <time.h> +#include <sys/time.h> #include "utils.h" int checkIfFileExists(char *path) @@ -42,5 +43,10 @@ char* getLine(FILE *dictionary, int lineNumber) int getRandomNumber(int min, int max) { + // Adding Randomize Time Values for Less Chances of Running into Seed Collisions + struct timeval randtime; + gettimeofday(&randtime,NULL); + srand((randtime.tv_sec * 100 + time(NULL)) + (randtime.tv_usec / 100 - time(NULL))); + return ((rand() % (max - min + 1)) + 1); } |