Wikia

Wikihack

Source:NetHack 1.3d/rnd.c

2,032pages on
this wiki
Talk0

Below is the full text to rnd.c from the source code of NetHack 1.3d. To link to a particular line, write [[NetHack 1.3d/rnd.c#line123]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

Screenshots and source code from Hack are used under the CWI license.
1.    /*	SCCS Id: @(#)rnd.c	1.3	87/07/14
2.    /* rnd.c - version 1.0.2 */
3.    
4.    #define RND(x)	((rand()>>3) % x)
5.    
6.    rn1(x,y)	/* y <= rn1(x,y) < (y+x) */ 
7.    register x,y;
8.    {
9.    	return(RND(x)+y);
10.   }
11.   
12.   rn2(x)		/* 0 <= rn2(x) < x */
13.   register x;
14.   {
15.   	return(RND(x));
16.   }
17.   
18.   rnd(x)		/* 1 <= rnd(x) <= x */
19.   register x;
20.   {
21.   	return(RND(x)+1);
22.   }
23.   
24.   d(n,x)		/* n <= d(n,x) <= (n*x) */
25.   register n,x;
26.   {
27.   	register tmp = n;
28.   
29.   	while(n--) tmp += RND(x);
30.   	return(tmp);
31.   }

Around Wikia's network

Random Wiki