From 650fb220913f79b5016dcfe1e497493619bf6fa2 Mon Sep 17 00:00:00 2001 From: rafa_99 Date: Fri, 4 Dec 2020 01:34:14 +0000 Subject: Found a good algorithm to randomize seeds --- utils.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utils.c b/utils.c index 54800bc..49a6069 100644 --- a/utils.c +++ b/utils.c @@ -2,6 +2,7 @@ #include #include #include +#include #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); } -- cgit v1.2.3