Merge from vendor branch OPENSSL:
[games.git] / games / hack / rnd.c
CommitLineData
984263bc
MD
1/* rnd.c - version 1.0.2 */
2/* $FreeBSD: src/games/hack/rnd.c,v 1.5 1999/11/16 10:26:38 marcel Exp $ */
c7106d58 3/* $DragonFly: src/games/hack/rnd.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */
984263bc 4
c7106d58 5#include "hack.h"
984263bc
MD
6
7#define RND(x) (random() % x)
8
c7106d58
PA
9int
10rn1(int x, int y)
984263bc
MD
11{
12 return(RND(x)+y);
13}
14
c7106d58
PA
15int
16rn2(int x)
984263bc
MD
17{
18 return(RND(x));
19}
20
c7106d58
PA
21int
22rnd(int x)
984263bc
MD
23{
24 return(RND(x)+1);
25}
26
c7106d58
PA
27int
28d(int n, int x)
984263bc
MD
29{
30 int tmp = n;
31
32 while(n--) tmp += RND(x);
33 return(tmp);
34}