I proposed a new series to the other Mad Scientists, the idea for which is that we all put our heads together to discuss and try to solve particularly thorny problems. The response was positive, and @Zed suggested a number of problems to examine (and also “Lab Session” as a title). The first on his list was the scenario of giving orders to NPCs that are in a location different from that of the PC, so we can use that for a trial run.
Note that the ultimate goal of this series would be to make suggestions for improving Inform, so please don’t hesitate to contribute your own questions and ideas to the mix, even if your interest in the technical side of things is limited. This isn’t supposed to be an exercise for mad scientists only – it’s more like “open house” for the mad science labs.
THIS THREAD’S TARGET
An NPC which is in a different part of the world model than the PC can be a tricky situation, and it has been that way since Inform 6 (see Ex 101 in DM4). Scope determination is fundamentally PC-centric (though some improvements have been made in I7), and the concept of scope is interlinked with both the in-world visibility relation
and states of both in-world (PC, NPC) and out-of-world (human player) knowledge.
[EDIT: This Lab Session has been concluded. A status report is listed at the end of this post.]
DEFINING THE PROBLEM
So… it’s probably a good idea to get a clear definition of the problem before trying to solve it. These are the core issues as I understand them:
- The rules for NPC scope determination are not the same as those for PC scope determination.
- Floating objects (e.g. backdrops, two-sided doors) aren’t relocated when considering NPC scope.
- It’s hard to interpret how the parser should handle a word when modeling three different knowledge states (human player, PC and NPC).
(Are there any other aspects of the situation that I didn’t cover, Zed?)
BACKGROUND READING
This is a complicated subject that is addressed very little in the primary documentation for Inform 7. For an overview, I would suggest:
- scope as explained by @drpeterbatesuk: The Mysteries of Aaron Reed's Remembering Extension (and a solution) - #19 by drpeterbatesuk
- a thread exploring the practical difficulties of this type of situation: Giving instructions over a radio
- write-up on important technical details regarding
backdrops
: In 10.1.2, only one of multiple statements to place a backdrop is implemented when at least one is implemented as a routine
DEMONSTRATING THE PROBLEM
To better illustrate issues #1 and #2, consider the following:
Sample Scenario
"Scope for NPCs"
Cavern is a room. "A dark pit is in the center of the cavern. Rough stairs cut into its outer edge descend into darkness." The player is in Cavern.
There is a backdrop called a fissure. "It's pretty far up." It is everywhere. It is not scenery.
Rule for writing a paragraph about the fissure:
say "High above, a slash of brightness marks the fissure from which you first entered the caves."
Pit is a dark room. It is down from Cavern.
A person called Robot A is in Pit.
A gold nugget is in Pit.
Alcove is a dark room. It is east from Pit.
To decide whether (O1 - object) is in scope for (O2 - object):
(- (TestScope({O1}, {O2})) -).
To show complete scope for (P - person):
let scoped be a list of objects;
repeat with obj running through objects:
if obj is in scope for P, add obj to scoped;
say "In scope for [P]: [scoped]."
Every turn:
repeat with P running through people:
show complete scope for P.
Test me with "z / down / east".
which will produce output demonstrating some potentially unexpected behavior:
Sample Transcript
Cavern
A dark pit is in the center of the cavern. Rough stairs cut into its outer edge descend into darkness.
High above, a slash of brightness marks the fissure from which you first entered the caves.
>z
Time passes.
In scope for yourself: yourself and fissure.
In scope for Robot A: Robot A and gold nugget.
>down
Darkness
It is pitch dark, and you can't see a thing.
In scope for yourself: yourself.
In scope for Robot A: yourself, fissure, Robot A and gold nugget.
>east
Darkness
It is pitch dark, and you can't see a thing.
In scope for yourself: yourself.
In scope for Robot A: Robot A and gold nugget.
For issue #3, the key question is: If an item A is in scope for the NPC but not the PC, how should the game handle a human player’s command that tries to reference item A?
Let’s fire up those bunsen burners and see what we can do!
CURRENT STATUS
Exciting things have been accomplished! So far, we’ve managed:
- Three subproblems:
- Handling of scope is different between PCs and NPCs - done
- Floating objects don’t relocate for NPCs - done
- Mediation of knowledge state of PC vs. NPC vs. human player - done
- Scope creep:
4) scope extension and visibility extension are conflated - done
5) visibility and touchability are PC-centric - done
6) Determine object illumination relative to the viewer’s position - done
7) Unify all sensory tests under the same object search framework - done
8) Driving scope from senses available to the PC - done
9) Extending senses beyond a range allowed by the world model - done
10) Arranging better feedback about the cause of failed actions (i.e. preservingreason the action failed
) - done
11) Support for extending sensory model - done
The scope creep isn’t just overkill, because another item on Zed’s list of suggested topics is “achieving (or approaching) PC-NPC equivalence,” which can be considered a subproblem of the goal here.