NetBSD/games/hack/rnd.c

45 lines
563 B
C
Raw Normal View History

1997-10-19 20:56:41 +04:00
/* $NetBSD: rnd.c,v 1.4 1997/10/19 16:59:39 christos Exp $ */
#include <sys/cdefs.h>
#ifndef lint
1997-10-19 20:56:41 +04:00
__RCSID("$NetBSD: rnd.c,v 1.4 1997/10/19 16:59:39 christos Exp $");
#endif /* not lint */
#include <stdlib.h>
#include "hack.h"
#include "extern.h"
1993-03-21 12:45:37 +03:00
#define RND(x) ((random()>>3) % x)
1997-10-19 20:56:41 +04:00
int
rn1(x, y)
int x, y;
1993-03-21 12:45:37 +03:00
{
1997-10-19 20:56:41 +04:00
return (RND(x) + y);
1993-03-21 12:45:37 +03:00
}
1997-10-19 20:56:41 +04:00
int
1993-03-21 12:45:37 +03:00
rn2(x)
1997-10-19 20:56:41 +04:00
int x;
1993-03-21 12:45:37 +03:00
{
1997-10-19 20:56:41 +04:00
return (RND(x));
1993-03-21 12:45:37 +03:00
}
1997-10-19 20:56:41 +04:00
int
1993-03-21 12:45:37 +03:00
rnd(x)
1997-10-19 20:56:41 +04:00
int x;
1993-03-21 12:45:37 +03:00
{
1997-10-19 20:56:41 +04:00
return (RND(x) + 1);
1993-03-21 12:45:37 +03:00
}
1997-10-19 20:56:41 +04:00
int
d(n, x)
int n, x;
1993-03-21 12:45:37 +03:00
{
1997-10-19 20:56:41 +04:00
int tmp = n;
1993-03-21 12:45:37 +03:00
1997-10-19 20:56:41 +04:00
while (n--)
tmp += RND(x);
return (tmp);
1993-03-21 12:45:37 +03:00
}