summaryrefslogtreecommitdiffstats
path: root/monop
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2008-02-24 02:58:33 +0000
committerdholland <dholland@NetBSD.org>2008-02-24 02:58:33 +0000
commit56db4783cf1b27df277d9ed01bcdf78c716c2804 (patch)
tree9e2a1fc06e20b1ab15b6cd5c6d064847f3e89574 /monop
parent448eded248530890acc8cc54c3698371737ece54 (diff)
downloadbsdgames-darwin-56db4783cf1b27df277d9ed01bcdf78c716c2804.tar.gz
bsdgames-darwin-56db4783cf1b27df277d9ed01bcdf78c716c2804.tar.zst
bsdgames-darwin-56db4783cf1b27df277d9ed01bcdf78c716c2804.zip
We do not need special code for pdp11. Also, because random() returns all
good bits (unlike rand()) we can simplify this.
Diffstat (limited to 'monop')
-rw-r--r--monop/roll.c30
1 files changed, 4 insertions, 26 deletions
diff --git a/monop/roll.c b/monop/roll.c
index f5372c70..43f42fc1 100644
--- a/monop/roll.c
+++ b/monop/roll.c
@@ -1,4 +1,4 @@
-/* $NetBSD: roll.c,v 1.11 2008/02/24 01:57:34 dholland Exp $ */
+/* $NetBSD: roll.c,v 1.12 2008/02/24 02:58:33 dholland Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)roll.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: roll.c,v 1.11 2008/02/24 01:57:34 dholland Exp $");
+__RCSID("$NetBSD: roll.c,v 1.12 2008/02/24 02:58:33 dholland Exp $");
#endif
#endif /* not lint */
@@ -46,36 +46,14 @@ __RCSID("$NetBSD: roll.c,v 1.11 2008/02/24 01:57:34 dholland Exp $");
* This routine rolls ndie nside-sided dice.
*/
-#if defined(pdp11)
-#define MAXRAND 32767L
-
-int
-roll(ndie, nsides)
- int ndie, nsides;
-{
- long tot;
- unsigned n, r;
-
- tot = 0;
- n = ndie;
- while (n--)
- tot += rand();
- return (int) ((tot * (long) nsides) / ((long) MAXRAND + 1)) + ndie;
-}
-
-#else
-
int
roll(ndie, nsides)
int ndie, nsides;
{
- int tot, r;
- double num_sides;
+ int tot;
- num_sides = nsides;
tot = 0;
while (ndie--)
- tot += (r = random()) * (num_sides / RAND_MAX) + 1;
+ tot += (random() % nsides) + 1;
return tot;
}
-#endif