diff options
| author | Ben Winston | 2025-10-05 14:40:51 -0400 |
|---|---|---|
| committer | Ben Winston | 2025-10-05 14:42:21 -0400 |
| commit | cf26d8ff753fcb8ef15bb7390afc61cafa546e73 (patch) | |
| tree | d6c150d08bd6e72b10184e07c35c5674fd1420ff /yhtz.c | |
| parent | efb46d3e1760ce9241d417f7bff8dcf15e534c37 (diff) | |
Diffstat (limited to 'yhtz.c')
| -rw-r--r-- | yhtz.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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() { |
