From bfb149ab182f4c873c3c8eed8a00bdb81539513a Mon Sep 17 00:00:00 2001 From: dholland Date: Mon, 20 Jul 2009 06:43:18 +0000 Subject: [PATCH] Use random() instead of rand(), and seed with time instead of pid. --- robots/main.c | 7 ++++--- 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 #include #include +#include #include #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; } -- 2.47.1