1 1.4 christos /* $NetBSD: rnd.c,v 1.4 1997/10/19 16:59:39 christos Exp $ */ 2 1.4 christos 3 1.4 christos #include <sys/cdefs.h> 4 1.2 mycroft #ifndef lint 5 1.4 christos __RCSID("$NetBSD: rnd.c,v 1.4 1997/10/19 16:59:39 christos Exp $"); 6 1.4 christos #endif /* not lint */ 7 1.4 christos 8 1.4 christos #include <stdlib.h> 9 1.4 christos #include "hack.h" 10 1.4 christos #include "extern.h" 11 1.1 cgd 12 1.1 cgd #define RND(x) ((random()>>3) % x) 13 1.1 cgd 14 1.4 christos int 15 1.4 christos rn1(x, y) 16 1.4 christos int x, y; 17 1.1 cgd { 18 1.4 christos return (RND(x) + y); 19 1.1 cgd } 20 1.1 cgd 21 1.4 christos int 22 1.1 cgd rn2(x) 23 1.4 christos int x; 24 1.1 cgd { 25 1.4 christos return (RND(x)); 26 1.1 cgd } 27 1.1 cgd 28 1.4 christos int 29 1.1 cgd rnd(x) 30 1.4 christos int x; 31 1.1 cgd { 32 1.4 christos return (RND(x) + 1); 33 1.1 cgd } 34 1.1 cgd 35 1.4 christos int 36 1.4 christos d(n, x) 37 1.4 christos int n, x; 38 1.1 cgd { 39 1.4 christos int tmp = n; 40 1.1 cgd 41 1.4 christos while (n--) 42 1.4 christos tmp += RND(x); 43 1.4 christos return (tmp); 44 1.1 cgd } 45