commit 162f59d5d402ba056cdf4bcb827e999d0bd24ca9
parent be1fb705d3a882cb48e650355d4cba5352c45604
Author: Wilson Gheen <wilson@wilsonrgheen.com>
Date: Sun, 18 Dec 2022 06:15:27 -0600
Enable keeping move recent seed, for debugging
Diffstat:
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tictactoe.h b/tictactoe.h
@@ -1,3 +1,4 @@
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -19,7 +20,13 @@ static _Bool srand_seeded = 0;
static int get_rand(int max_excl) {
if (!srand_seeded) {
- srand(time(NULL));
+ time_t seed = time(NULL);
+ FILE *f = fopen("seeds", "w");
+ if(f) {
+ fprintf(f, "%d\n", seed);
+ fclose(f);
+ }
+ srand(seed);
srand_seeded = 1;
}
return rand() % max_excl;