newlevel () { int i, j; initstufflist (); /* Delete the list of items */ droppedscare = 0; /* Old stuff gone */ maxobj = 22; /* Reset maximum # of objs */ newmonsterlevel (); /* Do new monster stuff */ exploredlevel = 0; /* New level */ aggravated = 0; /* Old monsters gone */ beingstalked = 0; /* Old monsters gone */ darkdir = NONE; darkturns = 0; /* Not arching old monster */ stairrow = NONE; staircol = 0; /* Get rid of old stairs */ missedstairs = 0; newdoors = doorlist; /* Clear door list */ goalr = goalc = NONE; /* Old goal invalid */ trapr = trapc = NONE; /* Old traps are gone */ foundarrowtrap = foundtrapdoor = 0; /* Old traps are gone */ teleported = 0; /* Not teleported yet */ attempt = 0; /* Haven't search for doors yet */ usesynch = 0; /* Force a new inventory */ compression = Level < 13; /* Set move compression */ newarmor = newweapon = newring = 1; /* Reevaluate our items */ foundnew (); /* Reactivate all rules */ /* * Clear the highlevel map */ for (i = 0; i < 9; i++) levelmap[i] = 0; for (i = 0; i < 9; i ++) for (j = 0; j < 9; j ++) zonemap[i][j] = (i == j); zone = NONE; /* * Clear the lowlevel map */ for (i = 1; i < 23; i++) for (j = 0; j < 80; j++) /* Forall screen positions */ { scrmap[i][j] = 0; timessearched[i][j] = 0; updatepos (screen[i][j], i, j); } atrow0 = atrow; atcol0 = atcol; set (ROOM); setnewgoal (); timestosearch = k_door / 5; }
int strategize () { dwait (D_CONTROL, "Strategizing..."); /* If replaying, instead of making an action, return the old one */ if (replaying) return (replaycommand ()); /* Clear any messages we printed last turn */ if (msgonscreen) { at (0,0); clrtoeol (); msgonscreen = 0; at (row,col); } /* ----------------------- Production Rules --------------------------- */ if (fightmonster ()) /* We are under attack! */ return (1); if (fightinvisible ()) /* Claude Raines! */ return (1); if (tomonster ()) /* Go play with the pretty monster */ return (1); if (shootindark ()) /* Shoot arrows in dark rooms */ return (1); if (handleweapon ()) /* Play with the nice sword */ { dwait (D_BATTLE, "Switching to sword [1]"); return (1); } if (light ()) /* Fiat lux! Especially if we lost */ return (1); /* a monster from view. */ if (dinnertime ()) /* Soups on! */ return (1); /* * These variables are short term memory. Slowed and * cancelled are fuses which are disabled after a small * number of turns. */ lyinginwait = 0; /* No more monsters to wait for */ if (foughtmonster) foughtmonster--; /* Turns since fought monster */ if (slowed) slowed--; /* Turns since we slowed a monster */ if (cancelled) cancelled--; /* Turns since we zapped 'cancel' */ if (beingheld) beingheld--; /* Turns since held by a fungus */ /* ---- End of short term memory modification ---- */ if (dropjunk ()) /* Send it back */ return (1); if (readscroll ()) /* Get out the reading glasses */ return (1); /* Must come before handlearmor() */ if (handlearmor ()) /* Play dressup */ return (1); if (quaffpotion ()) /* Glug glug glug ... */ return (1); /* Must come before handlering() */ if (handlering ()) /* We are engaged! */ return (1); if (blinded && grope (50)) /* Who turned out the lights */ { display ("Blinded, groping..."); return (1); } if (aftermelee ()) /* Wait for lingering monsters */ return (1); if (tostuff ()) /* Pick up the play pretty */ return (1); if (restup ()) /* Yawn! */ return (1); if (goupstairs (NOTRUNNING)) /* Up we go! Make sure that we get */ return (1); /* a better rank on the board. */ if (trywand ()) /* Try to use a wand */ return (1); if (gotowardsgoal ()) /* Keep on trucking */ return (1); if (exploreroom ()) /* Search the room */ return (1); if (archery ()) /* Try to position for fight */ return (1); if (pickupafter ()) /* Look for stuff dropped by arched mon */ return (1); if (plunge ()) /* Plunge mode */ return (1); if (findarrow ()) /* Do we have an unitialized arrow? */ return (1); if (findroom ()) /* Look for another room */ return (1); /* * 'attempt' records the number of times we have completely searched * this level for secret doors. If attempt is greater than 0, then we * have failed once to find the stairs and go down. If this happens * three times, there could be amonster sleeping on the stairs. We set * the SLEEPER bit for each square with a sleeping monster. Go find * such a monster and kill it to see whether (s)he was on the stairs). */ if (attempt > 4 && makemove (ATTACKSLEEP, genericinit, sleepvalue, REUSE)) { display ("No stairs, attacking sleeping monster..."); return (1); } if (Level>1 && larder>0 && doorexplore ()) /* Grub around */ return (1); if (godownstairs (NOTRUNNING)) /* Down we go! */ return (1); if ((Level<2 || larder<1) && doorexplore()) /* Grub around anyway */ return (1); /* * If we think we are on the stairs, but arent, maybe they were moved * (ie we were hallucinating when we saw them last time). */ if (on (STAIRS) && (atrow != stairrow || atcol != staircol)) { dwait (D_ERROR, "Stairs moved!"); findstairs (NONE, NONE); return (1); } /* * If we failed to find the stairs, explore each possible secret door * another ten times. */ while (attempt++ < MAXATTEMPTS) { timestosearch += max (3, k_door / 5); foundnew (); if (doorexplore ()) return (1); } /* * Don't give up, start all over! */ newlevel (); display ("I would give up, but I am too stubborn, starting over..."); return (grope (10)); }