Mercurial > hg > early-roguelike
comparison rogue4/prob.c @ 12:9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
author | edwarj4 |
---|---|
date | Sat, 24 Oct 2009 16:52:52 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
11:949d558c2162 | 12:9535a08ddc39 |
---|---|
1 /* | |
2 * | |
3 * Rogue: Exploring the Dungeons of Doom | |
4 * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman | |
5 * All rights reserved. | |
6 * | |
7 * See the file LICENSE.TXT for full copyright and licensing information. | |
8 */ | |
9 | |
10 # include <curses.h> | |
11 # include "rogue.h" | |
12 | |
13 # undef max | |
14 | |
15 # define TRIES 10000 | |
16 | |
17 static char *sccsid = "@(#)prob.c 1.3 (Berkeley) 12/17/81"; | |
18 | |
19 main(ac, av) | |
20 int ac; | |
21 char **av; | |
22 { | |
23 register unsigned int prob, prob2, exp; | |
24 register struct monster *mp; | |
25 register unsigned int max, min, i; | |
26 register unsigned int max2, min2; | |
27 | |
28 printf("%17.17s ----experience--- ----hit points---\n", ""); | |
29 printf("%17.17s %7s %4s %4s %7s %4s %4s lvl\n", "monster", "avg", "min", "max", "avg", "min", "max", "max hp"); | |
30 seed = 0; | |
31 for (mp = monsters; mp < &monsters[26]; mp++) { | |
32 i = TRIES; | |
33 prob2 = prob = 0; | |
34 min2 = min = 30000; | |
35 max2 = max = 0; | |
36 while (i--) { | |
37 if ((exp = roll(mp->m_stats.s_lvl, 8)) < min2) | |
38 min2 = exp; | |
39 if (exp > max2) | |
40 max2 = exp; | |
41 prob2 += exp; | |
42 mp->m_stats.s_maxhp = exp; | |
43 if ((exp = mp->m_stats.s_exp + exp_add(mp)) < min) | |
44 min = exp; | |
45 if (exp > max) | |
46 max = exp; | |
47 prob += exp; | |
48 } | |
49 printf("%17.17s: %7.2f %4d %4d %7.2f %4d %4d %3d\n", mp->m_name, ((double) prob) / TRIES, min, max, ((double) prob2) / TRIES, min2, max2, mp->m_stats.s_lvl); | |
50 fflush(stdout); | |
51 } | |
52 } | |
53 | |
54 exp_add(mp) | |
55 register struct monster *mp; | |
56 { | |
57 register unsigned int mod; | |
58 | |
59 if (mp->m_stats.s_lvl == 1) | |
60 mod = mp->m_stats.s_maxhp / 8; | |
61 else | |
62 mod = mp->m_stats.s_maxhp / 6; | |
63 if (mp->m_stats.s_lvl > 9) | |
64 mod *= 20; | |
65 else if (mp->m_stats.s_lvl > 6) | |
66 mod *= 4; | |
67 return mod; | |
68 } | |
69 | |
70 /* | |
71 * roll: | |
72 * roll a number of dice | |
73 */ | |
74 roll(number, sides) | |
75 register unsigned int number, sides; | |
76 { | |
77 register unsigned int dtotal = 0; | |
78 | |
79 dtotal = number; | |
80 while (number--) | |
81 dtotal += rnd(sides); | |
82 return dtotal; | |
83 } | |
84 | |
85 /* | |
86 * rnd: | |
87 * Pick a very random number. | |
88 */ | |
89 | |
90 | |
91 rnd(range) | |
92 register unsigned int range; | |
93 { | |
94 | |
95 return RN % range; | |
96 } |