SCCS-vsn: games/monop/roll.c 5.1
--- /dev/null
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)roll.c 5.1 (Berkeley) %G%";
+#endif not lint
+
+/*
+ * This routine rolls ndie nside-sided dice.
+ */
+
+# define reg register
+
+# ifndef vax
+# define MAXRAND 32767L
+
+roll(ndie, nsides)
+int ndie, nsides; {
+
+ reg long tot;
+ reg unsigned n, r;
+
+ tot = 0;
+ n = ndie;
+ while (n--)
+ tot += rand();
+ return (int) ((tot * (long) nsides) / ((long) MAXRAND + 1)) + ndie;
+}
+
+# else
+
+roll(ndie, nsides)
+reg int ndie, nsides; {
+
+ reg int tot, r;
+ reg double num_sides;
+
+ num_sides = nsides;
+ tot = 0;
+ while (ndie--)
+ tot += (r = rand()) * (num_sides / 017777777777) + 1;
+ return tot;
+}
+# endif