aboutsummaryrefslogtreecommitdiff
path: root/yhtz.c
diff options
context:
space:
mode:
Diffstat (limited to 'yhtz.c')
-rw-r--r--yhtz.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/yhtz.c b/yhtz.c
index 64b29a2..acaa3f5 100644
--- a/yhtz.c
+++ b/yhtz.c
@@ -1,6 +1,8 @@
+#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
+#include <sys/random.h>
/*
0000 0000 0000 0000 0000 0000 0000 0000
@@ -168,13 +170,20 @@ int turn_count(yhtz_state* state) {
return ret;
}
+uint16_t init_seed() {
+ uint8_t buf[2];
+ ssize_t ret = getrandom(&buf, 2, 0);
+ assert(ret == 2);
+ return (uint16_t)(buf[0] << 8 | buf[1]);
+}
+
void init_yhtz_state(yhtz_state* state) {
state->topflag_w_roll = 0;
state->topscore = 0;
state->botflag = 0;
state->botscore = 0;
state->dice = 0;
- state->seed = 13; /* TODO this isn't random */
+ state->seed = init_seed();
}
void main() {