1: /*
2: * This routine rolls ndie nside-sided dice.
3: */
4:
5: # define reg register
6:
7: # ifndef vax
8: # define MAXRAND 32767L
9:
10: roll(ndie, nsides)
11: int ndie, nsides; {
12:
13: reg long tot;
14: reg unsigned n, r;
15:
16: tot = 0;
17: n = ndie;
18: while (n--)
19: tot += rand();
20: return (int) ((tot * (long) nsides) / ((long) MAXRAND + 1)) + ndie;
21: }
22:
23: # else
24:
25: roll(ndie, nsides)
26: reg int ndie, nsides; {
27:
28: reg int tot, r;
29: reg double num_sides;
30:
31: num_sides = nsides;
32: tot = 0;
33: while (ndie--)
34: tot += (r = rand()) * (num_sides / 017777777777) + 1;
35: return tot;
36: }
37: # endif
Defined functions
roll
defined in line
25; used 8 times
Defined macros
reg
defined in line
5; used 5 times