summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorrafa_99 <rafa99@protonmail.com>2020-12-04 01:34:14 +0000
committerrafa_99 <rafa99@protonmail.com>2020-12-04 01:34:14 +0000
commit650fb220913f79b5016dcfe1e497493619bf6fa2 (patch)
tree00ef5590e07b493940c8eeeec748666797a846d7 /utils.c
parent2e4fb93e33b92e5546c6d17a53743ac3cfb7e86b (diff)
Found a good algorithm to randomize seeds
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index 54800bc..49a6069 100644
--- a/utils.c
+++ b/utils.c
@@ -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);
}