16 printf("Initialising...\n");
18 /* Initialize our LCG PRNG with parameters tested against
19 * Knuth vol. 2. by the original authors */
24 long seedval = (long)rand();
27 for (int i = 1; i <= NOBJECTS; i++) {
28 game.place[i] = LOC_NOWHERE;
31 for (int i = 1; i <= NLOCATIONS; i++) {
32 if (!(locations[i].description.big == 0 || tkey[i] == 0)) {
34 if (T_TERMINATE(travel[k]))
35 conditions[i] |= (1 << COND_FORCED);
39 /* Set up the game.atloc and game.link arrays.
40 * We'll use the DROP subroutine, which prefaces new objects on the
41 * lists. Since we want things in the other order, we'll run the
42 * loop backwards. If the object is in two locs, we drop it twice.
43 * Also, since two-placed objects are typically best described
44 * last, we'll drop them first. */
45 for (int i = NOBJECTS; i >= 1; i--) {
46 if (objects[i].fixd > 0) {
47 drop(i + NOBJECTS, objects[i].fixd);
48 drop(i, objects[i].plac);
52 for (int i = 1; i <= NOBJECTS; i++) {
53 int k = NOBJECTS + 1 - i;
54 game.fixed[k] = objects[k].fixd;
55 if (objects[k].plac != 0 && objects[k].fixd <= 0)
56 drop(k, objects[k].plac);
59 /* Treasure props are initially -1, and are set to 0 the first time
60 * they are described. game.tally keeps track of how many are
61 * not yet found, so we know when to close the cave. */
62 for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
63 if (objects[treasure].is_treasure) {
64 if (objects[treasure].inventory != 0)
65 game.prop[treasure] = -1;
66 game.tally = game.tally - game.prop[treasure];
69 game.conds = setbit(11);