aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2018-02-07 21:29:03 +0100
committertomsmeding <tom.smeding@gmail.com>2018-02-07 21:29:03 +0100
commit49722933a9a14eb7b708a56a690a2b199e878f44 (patch)
treebdb11fdfd65f7afd30b2f3cf64af01a06cd8f4ba
parent0fb26b55fce17d22806a83846827c92f2b884736 (diff)
Better randomness
-rw-r--r--main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/main.c b/main.c
index d9f7984..7ac20b2 100644
--- a/main.c
+++ b/main.c
@@ -67,7 +67,7 @@ static void persist(struct board *bd){
// returns false iff game over
static bool spawn(struct board *bd){
- int idx=rand()%7;
+ int idx=random()%7;
bd->stone=stones[idx];
bd->stx=WID/2-1;
bd->sty=0;
@@ -152,7 +152,11 @@ static void rotR(struct board *bd){
int main(void){
- srand(time(NULL));
+ {
+ struct timeval tv;
+ gettimeofday(&tv,NULL);
+ srandom(tv.tv_sec*1000000L+tv.tv_usec);
+ }
initkeyboard(false);
atexit(endkeyboard);