13 struct game_t game = {
14 .dloc[1] = LOC_KINGHALL,
15 .dloc[2] = LOC_WESTBANK,
17 .dloc[4] = LOC_ALIKE3,
18 .dloc[5] = LOC_COMPLEX,
20 /* Sixth dwarf is special (the pirate). He always starts at his
21 * chest's eventual location inside the maze. This loc is saved
22 * in chloc for ref. The dead end in the other maze has its
23 * loc stored in chloc2. */
24 .dloc[6] = LOC_DEADEND12,
25 .chloc = LOC_DEADEND12,
26 .chloc2 = LOC_DEADEND13,
35 /* Initialize our LCG PRNG with parameters tested against
36 * Knuth vol. 2. by the original authors */
45 printf("Initialising...\n");
48 long seedval = (long)rand();
51 for (int i = 1; i <= NOBJECTS; i++) {
52 game.place[i] = LOC_NOWHERE;
55 for (int i = 1; i <= NLOCATIONS; i++) {
56 if (!(locations[i].description.big == 0 || tkey[i] == 0)) {
58 if (T_TERMINATE(travel[k]))
59 conditions[i] |= (1 << COND_FORCED);
63 /* Set up the game.atloc and game.link arrays.
64 * We'll use the DROP subroutine, which prefaces new objects on the
65 * lists. Since we want things in the other order, we'll run the
66 * loop backwards. If the object is in two locs, we drop it twice.
67 * Also, since two-placed objects are typically best described
68 * last, we'll drop them first. */
69 for (int i = NOBJECTS; i >= 1; i--) {
70 if (objects[i].fixd > 0) {
71 drop(i + NOBJECTS, objects[i].fixd);
72 drop(i, objects[i].plac);
76 for (int i = 1; i <= NOBJECTS; i++) {
77 int k = NOBJECTS + 1 - i;
78 game.fixed[k] = objects[k].fixd;
79 if (objects[k].plac != 0 && objects[k].fixd <= 0)
80 drop(k, objects[k].plac);
83 /* Treasure props are initially -1, and are set to 0 the first time
84 * they are described. game.tally keeps track of how many are
85 * not yet found, so we know when to close the cave. */
86 for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
87 if (objects[treasure].is_treasure) {
88 if (objects[treasure].inventory != 0)
89 game.prop[treasure] = -1;
90 game.tally = game.tally - game.prop[treasure];
93 game.conds = setbit(11);