Finding a best route through light-filled rooms only, leaving aside any that might be dark.

Suppose we're simulating a situation where the player needs to travel through lit areas only, but we want to give him some hints about which way might be safe. Here we'll find our best route through light-filled rooms.

The slightly tricky part is that it's not necessarily easy to tell whether a room has a lamp in it. We may say "if the Crypt is lighted", but that only tells us whether it has been declared to be inherently lighted or dark, not whether it happens to contain a light source that the player would be able to see if he went in.

The easiest way to get around this is to create an object -- the light-meter; place it in the target location; and check whether it "can see" a lit object. This preserves all the usual rules about open and closed containers, transparency, etc.

"Unblinking"
Section 1 - Procedure
The light-meter is a privately-named scenery thing.
Definition: a room (called the target room) is light-filled:
   if the target room is lighted:
      yes;
   move the light-meter to the target room;
   let the answer be false;
   if the light-meter can see a lit thing:
      now the answer is true;
   now the light-meter is nowhere;
   decide on the answer.

That done, we're free to use our best-route phrases to choose a particular route.

Section 2 - Scenario
The Tomb of Angels is a room. "This ancient underground tomb is lightless but for a few shafts from the surface. Everywhere in the shadows are carved angels, their faces worn away by water and pollution, their wings little more than nubs."
The Upward Path is above the Tomb of Angels. It is dark. "The staircase switches back on itself many times as it ascends towards the Crash Site."
A container called the sarcophagus is in the Upward Path. It is closed and openable. "A sarcophagus rests in the niche here, [if open]the lid pushed aside[otherwise]the lid firmly in place[end if]."
The Crash Site is above the Upward Path. "The ceiling has wholly caved in here, and the belly of the spaceship above you is visible -- including the escape hatch."
A candle is a kind of thing. A candle is usually lit. The player carries four candles.
After looking when the location is not the Crash Site:
   if the best route from the location to the Crash Site through light-filled rooms is a direction (called next way):
      say "It looks like there's a safe, lit path [if the number of moves from the location to the Crash Site through light-filled rooms is 1]straight[otherwise]if you go[end if] [next way].";
   otherwise:
      say "It looks like there is no fully lit path from here to the Crash Site."
Test me with "up / drop candle / down / up / take the candle / open sarcophagus / put candle in sarcophagus / down / up / close sarcophagus / d".
Test me with "up / drop candle / down / up / take the candle / open sarcophagus / put candle in sarcophagus / down / up / close sarcophagus / d".
Tomb of Angels
This ancient underground tomb is lightless but for a few shafts from the surface. Everywhere in the shadows are carved angels, their faces worn away by water and pollution, their wings little more than nubs.

It looks like there is no fully lit path from here to the Crash Site.

>(Testing.)

>[1] up

Upward Path
The staircase switches back on itself many times as it ascends towards the Crash Site.

A sarcophagus rests in the niche here, the lid firmly in place.

It looks like there's a safe, lit path straight up.

>[2] drop candle
Dropped.

>[3] down

Tomb of Angels
This ancient underground tomb is lightless but for a few shafts from the surface. Everywhere in the shadows are carved angels, their faces worn away by water and pollution, their wings little more than nubs.

It looks like there's a safe, lit path if you go up.

>[4] up

Upward Path
The staircase switches back on itself many times as it ascends towards the Crash Site.

A sarcophagus rests in the niche here, the lid firmly in place.

You can also see a candle (providing light) here.

It looks like there's a safe, lit path straight up.

>[5] take the candle
Taken.

>[6] open sarcophagus
You open the sarcophagus.

>[7] put candle in sarcophagus
You put the candle into the sarcophagus.

>[8] down

Tomb of Angels
This ancient underground tomb is lightless but for a few shafts from the surface. Everywhere in the shadows are carved angels, their faces worn away by water and pollution, their wings little more than nubs.

It looks like there's a safe, lit path if you go up.

>[9] up

Upward Path
The staircase switches back on itself many times as it ascends towards the Crash Site.

A sarcophagus rests in the niche here, the lid pushed aside.

It looks like there's a safe, lit path straight up.

>[10] close sarcophagus
You close the sarcophagus.

>[11] d

Tomb of Angels
This ancient underground tomb is lightless but for a few shafts from the surface. Everywhere in the shadows are carved angels, their faces worn away by water and pollution, their wings little more than nubs.

It looks like there is no fully lit path from here to the Crash Site.

An important word of caution: this method would give false negatives if there were a backdrop lightsource, such as the moon, providing light to the Upward Path. This is because backdrops are actually moved around the map by Inform during play, following the player around. So if the moon backdrop is in the Crash Site with the player, it will not be in the Upward Path as well -- even if it's scheduled to move there as soon as the player does.