diff options
author | dholland <dholland@NetBSD.org> | 2009-07-20 06:43:18 +0000 |
---|---|---|
committer | dholland <dholland@NetBSD.org> | 2009-07-20 06:43:18 +0000 |
commit | bfb149ab182f4c873c3c8eed8a00bdb81539513a (patch) | |
tree | 85c024ddd0fdbcfb6334626e4d1baaf9f36d9d42 /robots | |
parent | c723a928778be55849c00d5cc692bf522bb8dae3 (diff) | |
download | bsdgames-darwin-bfb149ab182f4c873c3c8eed8a00bdb81539513a.tar.gz bsdgames-darwin-bfb149ab182f4c873c3c8eed8a00bdb81539513a.tar.zst bsdgames-darwin-bfb149ab182f4c873c3c8eed8a00bdb81539513a.zip |
Use random() instead of rand(), and seed with time instead of pid.
Diffstat (limited to 'robots')
-rw-r--r-- | robots/main.c | 7 | ||||
-rw-r--r-- | robots/rnd_pos.c | 6 |
2 files changed, 7 insertions, 6 deletions
diff --git a/robots/main.c b/robots/main.c index c106a96c..9868403a 100644 --- a/robots/main.c +++ b/robots/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.28 2009/07/20 06:39:06 dholland Exp $ */ +/* $NetBSD: main.c,v 1.29 2009/07/20 06:43:18 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\ #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: main.c,v 1.28 2009/07/20 06:39:06 dholland Exp $"); +__RCSID("$NetBSD: main.c,v 1.29 2009/07/20 06:43:18 dholland Exp $"); #endif #endif /* not lint */ @@ -50,6 +50,7 @@ __RCSID("$NetBSD: main.c,v 1.28 2009/07/20 06:39:06 dholland Exp $"); #include <fcntl.h> #include <signal.h> #include <stdlib.h> +#include <time.h> #include <unistd.h> #include "robots.h" @@ -167,7 +168,7 @@ main(int ac, char **av) stdscr = newwin(Y_SIZE, X_SIZE, 0, 0); } - srand(getpid()); + srandom(time(NULL)); if (Real_time) signal(SIGALRM, move_robots); do { diff --git a/robots/rnd_pos.c b/robots/rnd_pos.c index e5a0b4c3..65baea60 100644 --- a/robots/rnd_pos.c +++ b/robots/rnd_pos.c @@ -1,4 +1,4 @@ -/* $NetBSD: rnd_pos.c,v 1.8 2009/07/20 06:39:06 dholland Exp $ */ +/* $NetBSD: rnd_pos.c,v 1.9 2009/07/20 06:43:18 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)rnd_pos.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: rnd_pos.c,v 1.8 2009/07/20 06:39:06 dholland Exp $"); +__RCSID("$NetBSD: rnd_pos.c,v 1.9 2009/07/20 06:43:18 dholland Exp $"); #endif #endif /* not lint */ @@ -67,5 +67,5 @@ int rnd(int range) { - return rand() % range; + return random() % range; } |