Epistemology and Visibility

I’ve been looking through Eric Eve’s Epistemology extension for hints about how to implement the “lost” property/adjective for use in my Lost Items extension.

I’ve pretty much settled on the following:

[code]A thing can be losable.

Definition: A thing is lost if it is known and it is losable and it is not visible[/code]

…but I’m not totally sure what visible really means.

So my question regards this section of Epistemology:

Carry out looking (this is the mark items as seen when looking rule): unless in darkness begin; repeat with item running through things that are enclosed by the location begin; if the item is not enclosed by an opaque closed container, now the item is seen; end repeat; end unless.

Why is “visible” not used here? In addition to being a good deal of duplicated effort, it appears as though items in the room would be falsely marked visible if the player were inside a closed opaque container with a light source. Am I wrong? One could also argue that items in the player’s inventory are seen even in the dark.

I think “visible” means anything that is visible in the story world. So, if a coin is on a table inside a hidden room, it is a visible object to I7, even if the PC never went to such room.

So pointing the code to a visible thing would make every object out in the open seen.

No, “X is visible” means that the player can see X. (Via the visibility relation.) This is exactly the parser’s notion of scope – the code compiles to a scope test.

Is Eric here? I’d like to talk to him about why he didn’t use it in that case.

Possibly for efficiency reasons. Iterating through all objects and performing a scope test on each one is a nasty, nasty slow operation. (Even if you phrase it with an I7 description, i.e. “now all visible things are seen.”

It should be possible to optimize this to a single scope iteration, but that would take some I6-level hacking.

(Arguably that the I7 compiler should optimize that automatically, but it looks like that’s difficult – scope iterations aren’t a language-level construct.)

The comment right before that code might have something to do with it:

His e-mail address is at the bottom right corner of his home page at http://www.ecse.ukf.net/.

I swear, about 10 years ago, a chunk of my brain just burned right out. I never used to need spellcheck, and I would have caught something like that. My apologies for the multitude of times I’ve missed glaring things like that.

Do you think this could be done with an extension? I’m trying to guess what would be a good compromise between what could be done and what would work in many situations:

Of course if this could be done, it would be ideal:

[code]Include Quickly Visible by Inform Six Wizard.

Every turn when at least one nonplayer thing is visible:
Repeat with item running through quickly-visible things:[/code]

But this would probably be acceptable, and it might even make things faster if you had to do something more complex without changing the current scope:

[code]Include Scope Caching by Inform Six Wizard.

Every turn when at least one nonplayer thing is visible:
Mark visibility;
Repeat with item running through marked-visible things:
do some stuff.
Repeat with NPC running through marked-visible nonplayer people:
do some other stuff.[/code]

I’ve only barely tested this:

To iterate scope with (func - phrase thing -> nothing): (- LoopOverScope({func}-->1); -).

To iterate scope for (actor - thing) with (func - phrase thing -> nothing): (- LoopOverScope({func}-->1, {actor}); -).

To mungle (xx - thing) (this is mungling):
	say "Scope contains [xx]."
Instead of jumping:
	iterate scope with mungling.
	iterate scope for Floyd with mungling.

Thanks - I’ll try it out.

I didn’t know you could take a phrase as an argument and then execute it - that’s pretty cool. Is that an I6-only trick?

No, it came in with the new type system. You can say “apply PHRASE to VALUE” in I7, or a few other variants – see 21.3.

I’m using I6 here because LoopOverScope() is an I6 function.