aboutsummaryrefslogtreecommitdiff
path: root/hack/rnd.c
diff options
context:
space:
mode:
Diffstat (limited to 'hack/rnd.c')
-rw-r--r--hack/rnd.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/hack/rnd.c b/hack/rnd.c
new file mode 100644
index 0000000..b761dd9
--- /dev/null
+++ b/hack/rnd.c
@@ -0,0 +1,35 @@
+/* rnd.c - version 1.0.2 */
+/* $FreeBSD: src/games/hack/rnd.c,v 1.5 1999/11/16 10:26:38 marcel Exp $ */
+/* $DragonFly: src/games/hack/rnd.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */
+
+#include "hack.h"
+
+#define RND(x) (random() % x)
+
+int
+rn1(int x, int y)
+{
+ return (RND(x) + y);
+}
+
+int
+rn2(int x)
+{
+ return (RND(x));
+}
+
+int
+rnd(int x)
+{
+ return (RND(x) + 1);
+}
+
+int
+d(int n, int x)
+{
+ int tmp = n;
+
+ while (n--)
+ tmp += RND(x);
+ return (tmp);
+}