diff options
author | tomsmeding <tom.smeding@gmail.com> | 2018-02-07 21:29:03 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2018-02-07 21:29:03 +0100 |
commit | 49722933a9a14eb7b708a56a690a2b199e878f44 (patch) | |
tree | bdb11fdfd65f7afd30b2f3cf64af01a06cd8f4ba | |
parent | 0fb26b55fce17d22806a83846827c92f2b884736 (diff) |
Better randomness
-rw-r--r-- | main.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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); |