It doesnât help that the various (spatial) relations arenât completely defined together in any one place in the documentation.
There are 5 mutually-exclusive basic spatial relations between objects:
support- applicable only to supporters supporting things
containment- applicable only to rooms or containers containing things, or regions containing rooms or other regions
wearing- applicable only to people wearing things
carrying- applicable only to people carrying things
incorporation-applicable to any thing incorporating any thing
(incorporation is usually asserted by phrases or conditions such as âA is a part of Bâ or âif A is a part of Bâ although âB incorporates Aâ or âA is incorporated by Bâ are equivalent ways to express the same relation).
All these basic spatial relations describe only direct spatial relationships- so (counter-intuitively) if for example A contains B, which contains C, then A does NOT contain C; similarly if A carries B, which supports C, then A does NOT carry C.
There are two shorthand spatial relations (possession and holding) that combine basic direct spatial relationships:
A person has something if he/she/it (directly) wears or carries that something. Note that the built-in verb for the possession relation is âto haveâ not âto possessâ. Note that you canât assert âJohn has the teapotâ, because Inform thinks you might be trying to say that John has a property called âthe teapotâ. However, you can write ânow John has the teapotâ (since once play is underway, the time for allocating properties to things is long past) in which case it means the same as ânow John holds the teapotâ (see below) or also, in the case of a person (as here), âcarriesâ.
A thing or room holds (or is the holder of) something if he/she/it (directly) supports, contains, wears, carries or incorporates that something. âTo holdâ is somewhat complicated because (unlike âto haveâ) it can be used in a narrower sense as an assertion (âJohn holds the teapotâ) in which case it means the same as âto carryâ and therefore applies only to people. However, used as a condition (if the tray holds the teapot) it can apply to any thing or room, as a shorthand for any of the basic direct spatial relations, and similarly for example in phrases such as ânow the Crypt holds the coffinâ (containment) or ânow the tray holds the vaseâ (support). A person can therefore hold something in three different ways- by carrying, wearing or incorporating it. A container can hold something in two ways- by containing or incorporating it. A supporter can also hold something in two ways- by supporting or incorporating it. Rooms and regions can hold something only by containing it (rooms and regions cannot incorporate things). Finally, a thing that is not a supporter, container, region, room or person can hold something only by incorporating it (but see Addendum regarding moving things through code).
As an additional complication, although a region cannot hold a room it can hold one or more regions. Conversely, by a special rule a region can contain a room, this being the only situation where an object contains something without holding it. It follows that a room can be both contained and regionally contained by a region- indeed, if it is contained by a region, it must also be regionally contained by it (see below).
âVague holdingâ implies possession bug Inform currently has a bug (or at least an idiosyncracy) whereby in conditions of the form âif nothing holds the spannerâ or âif the spanner is held by somethingâ or âif a room holds the spannerâ- i.e. where the potential holder is left somewhat vague- holding has a different interpretation equivalent to the possession relation i.e. âif a thing holds the spannerâ is interpreted as âif a thing (which is a person) holds the spannerâ, so will be true only if the spanner is carried or worn. In other words it is equivalent to âif a thing has the spannerâ. This means that âif a room holds the spannerâ (interpreted as âif a room (which is a person) holds the spannerâ) can never be true. Similarly, âif nothing holds the spannerâ is actually equivalent to âif no one holds the spannerâ or âif nothing has the spannerâ and âif something holds the spannerâ is actually equivalent to âif someone holds the spannerâ or âif something has the spannerâ. This issue can be circumvented by rephrasing, for example, âif a room holds the spannerâ to âif the holder of the spanner is a roomâ, or âif nothing holds the spannerâ to âif the holder of the spanner is nothingâ.
In addition to the direct basic spatial relationships there are some indirect spatial relationships:
enclosure applicable to a room or thing directly or indirectly holding a thing or to a region directly or indirectly holding a region
room-containment applicable to a room directly or indirectly holding a thing
regional-containment applicable to a region directly or indirectly regionally-containing a room, or a thing enclosed by that room, or a backdrop [and since Ver.10 a region]
Because the first two of these indirect spatial relationships never specify exactly where and how the contents are held, they canât be used in assertions. You canât for example write âNow John encloses the teapotâ or âJohn encloses the teapotâ.
Room-containment also has no specific built-in verb. It usually appears in source as conditions like âif the Kitchen is the location of the teapotâ. You can define a verb if you like: âThe verb to locate means the room-containment relation. The verb to be located in means the reversed room-containment relationâ, after which you can write the equivalent condition âif the Kitchen locates the teapotâ or âif the teapot is located in the Kitchenâ although âif the Kitchen encloses the teapotâ or âif the teapot is enclosed by the Kitchenâ would do just as well. Note that âif the teapot is in the Kitchenâ always implies direct containment, not room-containment, so you must use âthe location ofâ or âenclosesâ or a specifically-defined verb like âlocatesâ if you want to include things indirectly contained or held by a room.
Regional-containment similarly has no built-in verb. It usually appears in source as conditions like âif the teapot is in the Mansionâ. This condition might theoretically be ambiguous as to whether is in implies âcontainsâ or âregionally containsâ but the ambiguity is usually resolved by whether the Mansion is a region (regional containment) or a room/container (containment). Rarely, the ambiguity is not so easily resolved- for example âif the teapot is in an-object-that-variesâ- since âan-object-that-variesâ (as an object variable) could conceivably be at various times a region, a room or a thing. The important point here is that if the Inform compiler can determine at the time of compilation that the putative âcontaining objectâ is definitely a region, it will apply a test of regional-containment rather than a test of containment. Note that the compiler can sometimes even work out that a variable must be a region, if you have created a global variable as âa region that variesâ or created a local variable to be a region with, for example, âlet my_putative_container be the Mansionâ. Conversely, the compiler cannot know whether a global or local variable declared to be an âobjectâ or âobject that variesâ is currently a region or not. If the putative âcontaining objectâ is definitely a room or container, or if it might conceivably be any of a region, room or container because it is an âobject that variesâ, then the compiler will apply a test of containment.
The best relation to use in determining whether a region is directly located within another region is, counter-intuitively and despite the suggestion of the I7 documentation, not regional-containment or containment but holding. âif Region A is regionally in Region Bâ always returns false. âIf Region A is in Region Bâ or âif Region A contains Region Bâ will also return false, because (as explained above) these phrases are interpreted by the compiler as testing regional-containment. Thus, although regions holding other regions also do contain them, itâs not straightforward to test a region for containment. Use âif Region A holds region Bâ or âif Region A is the holder of Region Bâ or âif Region B is held by Region Aâ. Enclosure can be used to include indirect holding between regions, e.g. âif Region A encloses Region Bâ. Avoid âif nothing holdsâ or âif a region holdsâ on account of the âvague holding implies carryingâ bug (see above). Rephrase these conditions to use âholder ofâ.
small print As noted above, it is possible to force the test of a region for containment by putting the holding region into âan object that variesâ, (or an object variable in a loop- e.g. repeat with obj_putative_container running through objectsâŚ). This can cause confusion, if you were expecting âinâ or âcontainsâ to test for regional-containment in these situations. It is also possible to force the test of a region for containment by invoking the relation explicitly in phrases such as âif the Mansion is (the region which relates to the East Wing by the containment relation)â (the brackets are required to help the compiler understand this phrase) or âthe list of regions that the Mansion relates to by the containment relationâ. See §13.13 in the documentation. Generally itâs just easier to use âIf the Mansion holdsâŚâ. [this information has been superseded since Ver.10: as of the time of writing (Ver.10.1.2)- regions now regionally-contain regions that they enclose (and also, unexpectedly, themselves!) so âif the East Wing is in the Mansionâ and âif the Mansion contains the East Wingâ now work as one would naturally assume they would and the need for âif the Mansion holds the East Wingâ has receded somewhat- but is still needed to easily test for direct containment.]
Importantly, since regions cannot hold rooms, and enclosure depends on direct or indirect holding, the âcascade of enclosureâ is broken between regions and rooms, so rooms or any of their contents are never enclosed by a region. Regional containment provides the indirect relation between regions and rooms or their contents.
Although assertions locating regions within regions (âthe East Wing is in the Mansionâ or equivalently and pedantically âthe East Wing is regionally in the Mansionâ) might appear to be asserting regional containment, in fact they create the containing and holding relations. Regions can never regionally-contain other regions. [until Ver 10 that is- they now can, and âthe East Wing is in the Mansionâ will also always indirectly creates a regional-containment relation] Such assertions imply a direct relation: (âthe East Wing is regionally in the Mansionâ implies that the Mansion directly holds and contains the East Wing) and they can therefore only be used to place a region (or a room- see below) within a region. In the above example, the East Wing must therefore be either a room or a region, not a container or some other thing or object. In the case of locating rooms in a region, either the regional containment or containment relation can be asserted (âthe East Wing contains the Kitchenâ, or âthe Kitchen is contained by the East Wingâ, or âthe Kitchen is in the East Wingâ (could imply either containment or regional containment), or âthe Kitchen is regionally in the East Wingâ (regional containment) and in either case both containment and regional containment relations are created. Assertions like this canât be made in play- ânow the East Wing is regionally in the Mansionâ, ânow the Kitchen is in the East Wingâ, or ânow the East Wing contains the Kitchenâ are all disallowed, as are phrases such as âmove the Kitchen to the East Wingâ, which produce a runtime error.
The explicit uses of room-containment and regional-containment in source are limited. The I6 routine [LocationOf] is used both to define âthe location ofâ and the room containment relation (should a verb such as âto room-containâ be defined for it in source)- but in practice âthe location of an-objectâ is generally used and room-containment is left redundant. Regional-containment exists as a means both to assert the relationships of regions and rooms and to allow phrases like âif the teapot is in the Mansionâ- regions can never enclose or hold rooms or the contents of rooms they regionally contain, so âif the Mansion encloses the teapotâ will never be true- assuming the Mansion is a region and the teapot a thing- and âthe holder of a-roomâ is always nothing. Note also that thereâs no directly equivalent built-in phrase âthe region of an-objectâ, perhaps because unlike rooms which cannot (in the Inform sense) contain rooms, large regions can encompass one or more smaller regions, so there is not necessarily a unique answer to âwhat region is this object within?â. However, every room provides a âmap regionâ property that gives the âlowest-levelâ region (if any) that regionally contains and contains it. So âthe map region of the location of a-thingâ is available. You can also use phrases like âlet my-list-of-regions be a list of the regions which relate to <a-thing> by the regional-containment relationâ to produce and search a full list of relevant regions. Note that as mentioned above, the map region of a room contains and regionally-contains but does not hold that room.
To summarise the complicated potential spatial relations of regions, they can:
containâ , hold and/or enclose other regions
contain roomsÇ
regionally-contain backdrops, or rooms, or things enclosed by those rooms [and since Ver 10] other regions
â but see notes above about testing for containment of regions
Ç Note that this appears to contradict the Inform 6 Designerâs Manual 4 (DM4) which states in â§24 The World Model Describedâ that âA room is (never) containedâ- but this is due to a difference in terminology: the corresponding âlawâ, which holds equally true in Inform 7, would be âA room is (never) heldâ.
Small-print (1) doors âthe location ofâ a two-way door is usually the one out of the two rooms it links that was first mentioned in the source text, this being defined by Inform as the âfront sideâ of the door. The exception to this is if the player is in the room on the âback sideâ of the door, in which case that becomes temporarily the location of the door. The room that contains the door defaults to its âfront sideâ but subsequently, becomes the room holding the most-recently-player-facing side of the door, (which may therefore be either the front side or the back side of the door). The location of a door also usually therefore contains that door (which therefore is in that location). However, the room which is the âother sideâ of the door, being the one not most-recently-player-facing, does not hold or contain it and the door therefore is not in that room. See the Addendum for why this is so. However, a paradoxical situation can arise if the door ends up either through code (e.g. ânow the oak door is in the Libraryâ), or through automatic repositioning via the wanderings of the player, in the room that is the âback sideâ of the door when the player is not also in that room. In this instance the location of the door will default back to being reported as the âfront sideâ, but the âback sideâ rather than the âfront sideâ will still contain and hold it. In short, the location of a two-way door is always the room containing its front side except when the playerâs location is the room containing its âback sideâ, in which case that room is the doorâs location. Furthermore, by a special rule a two-way door is always enclosed by the rooms to both front and back. The paradox created here is that the door is enclosed by one room which neither room-contains or contains or holds it, or indeed satisfies any of the basic spatial relations with it. This is the only situation in which an object encloses something it does not (directly or indirectly) hold. One-way doors are simply always contained, enclosed, located in and held by the one room they lead from.
Small-print (2) - Backdrops are equally complicated. The I7 documentation states that a backdrop has no location and is enclosed and contained by nothing, but this is not quite true. In general terms a backdrop is held and contained by the last room the player occupied where the backdrop was to be found- unless or until the places where the backdrop is to be found are changed and updated, or it is moved off-stage. See the Addendum for more detail and an explanation, plus the even stranger behaviour of a backdropâs location. Strangely, there is no simple condition in I7 that tests whether a backdrop will be found in a particular room when the player is not presently there. It can if required be provided by this simple example of I6 hackery-
To decide whether (B - a backdrop) is found in (R - a room): (- (BackdropLocation( {B}, {R} )) -);
Also, if a backdrop is found in one or more of the rooms regionally contained by a region, the regional-containment relation applies and the condition âif a-backdrop is regionally in a-regionâ is true- even if neither the current location of the player or the current location of the backdrop is. In this instance, the regionally of regionally in is required, not optional.
Inform also defines a number of what might be termed âcalculatedâ spatial relations, which can be tested for in conditions but not asserted:
adjacency applicable to a room which âis adjacent toâ a room
visibility applicable to a thing which âcan be seen byâ a thing
touchability applicable to a thing which âcan be touched byâ a thing
concealment applicable to a thing which âis concealed byâ a thing that holds it
These relations are determined by (sometimes complex) rules that are in part dependent on the simpler spatial relations described above (or in the case of adjacency, the various mapping relations) and they cannot therefore be simply asserted to be true or false. To make them so, the simpler spatial relations or other elements of the world state must be manipulated and/or the relevant rules must be written or altered.
As a useful shorthand, an âadjacent roomâ means one adjacent to the location of the player; a âtouchable thingâ means one the player can touch ; a âvisible thingâ means one the player can see â although the last of these, confusingly, has a subtly different meaning in the context of defining new actions:
The meaning of âvisible thingâ in Inform Many action definitions are akin to Watching is an action applying to one visible thing.
The choice of the word âvisibleâ in action definitions to distinguish objects anywhere in the universe (by way of contrast to those that are merely touchable, or actually carried), is one of the more confusing syntax features of Inform, as in this special context âvisibleâ can sometimes include things which the player cannot see. This is compounded by the parallel existence of a visibility relation that also makes use of the adjective âvisibleâ and which has a meaning that is both subtly different and more conventional. Any object, whether conventionally visible or not, is a âvisible thingâ in the context of action definitions. If this were not the case, the player would not ordinarily be able to invoke actions involving objects that are not physically enclosed by the same room as the player, the latter representing the absolute limits of conventional visibility.
Likewise the use of the word âthingâ in action definitions to mean âobjectâ- when elsewhere âthingâ means a subgroup of objects that, in the basic world model, are not rooms, directions or regions (see the Kinds tab in the Index of the Inform documentation).
In summary, in the context of action definitions, and action definitions alone, âvisible thingâ actually means âany objectâ.
Note that action definitions do not have any interest in âscopeâ- which defines which objects the parser can use to build an action in response to a typed command. Scope is enforced by grammar tokens (such as [something]) in Understand phrases (such as 'Understand âphotograph [something]â as photographing. Ordinarily, objects matched by grammar tokens must be âin scopeâ. Actions invoked directly by code e.g. âtry photographing the triffidâ need only match the action definition- they are unaffected by scope or the need to match grammar tokens.
Objects that âcan be seen by the playerâ- and which therefore satisfy the âvisibility relationâ and can be referred to in descriptions and conditions (as opposed to action definitions) as âvisibleâ objects- are usually âin scopeâ and vice versa, but there are multiple exceptions- for example in the dark, the playerâs possessions are in scope but not visible.
The qualifier âanyâ applied to objects (or descriptions of objects) appearing in tokens of grammar lines, e.g. â[any door] or [any closed container]â, allows them to override the requirement for such objects be in scope (or, looked at another way, brings said objects into scope for that particular action). 'Understand âopen [any closed container] as remote openingâ thereby allows the âremote openingâ action to be invoked on any closed container, in-or-out-of-play, anywhere in the game universe, whether in scope or not, as long as remote opening is defined as applying to a âvisible thingâ. Possibly more usefully, [any room], [any adjacent room] etc. therefore allow the player to invoke actions referring to rooms, which are never ordinarily in scope.
Note also that âin playâ has a technical meaning in Inform as an adjective that can be applied to objects, which is that the object in question is enclosed by a room. Even objects that by this definition are âout of playâ, such as directions, or other objects created âoff-stageâ or âremoved from playâ to ânowhereâ may be considered âvisible thingsâ in the context of action definitions if the scoping rules decide that they are nevertheless âin scopeâ. An âout of playâ object can also be said to âbe nowhereâ and an âin play objectâ to âbe somewhereâ.
Adjacency A room is adjacent to another room if it is possible to move directly from one to the other by a mapped direction- perhaps surprisingly, 2 rooms connected only by a door (regardless of whether the door is currently open or unlocked) are not adjacent to each other. Although the documentation states that adjacency applies only to two rooms, possibly as a bug it also sometimes applies to a room and a door, but that fact probably shouldnât be relied upon. As a convenience, the adjective âadjacentâ applies to any room adjacent to the playerâs current location.
Concealment The definition of concealment (as an adjective) is that a thing is concealed if its holder conceals it. The relation of concealment is governed by the verbs â concealsâ or âis concealed byâ through the activity âdeciding the concealed possessionsâ, which by default is an empty rulebook, meaning that nothing is concealed. New rules written regarding certain things (such as âMr Darcyâ), or things grouped under a description (such as âa personâ), or even the all-encompassing âsomethingâ, can decide according to any criteria they choose that they conceal any other given thing. The potentially concealed thing under consideration when the activity is run is called âthe particular possessionâ. An example rule might begin Rule for deciding the concealed possessions of a person who is wearing a cloak:
Anomalous treatment of concealment invoked by adjective vs. verb If a question regarding concealment is phrased using âconcealedâ as an adjective e.g. âif the pistol is concealedâ or âa list of concealed things in the locationâ the âdeciding the concealed possessionsâ activity is called regarding the holder of e.g. the pistol, or the holder of each of the things in the location in turn, so that only rules in the activity rulebook matching the holder (in the first example, if the holder of the pistol wears a cloak) will be considered. However, if the question is phrased as a condition regarding described or specified âconcealer(s)â and with âconcealâ as a verb, e.g. âif Mr Darcy conceals the pistolâ or âif the pistol is concealed by a womanâ âthereby invoking the concealment relation directly- the activity is called (in the first example) regarding Mr Darcy- and if Mr Darcy is wearing a cloak, the above rule will be considered whether or not Mr Darcy holds the pistol. If the rule itself doesnât ask whether or not Mr Darcy is the holder of the particular possession (the pistol), it may decide he is concealing a pistol that is not even in the same room. In this instance the conditions âif Mr Darcy conceals <some distant object>â or âif <some distant object> is concealed by somethingâ will test true, whereas âif <some distant object> is concealedâ will test false, and functionally the concealment will have no effect as the distant object will remain fully visible and interactive. EDIT: (This anomaly has been partially corrected in v10- by default (if no spatial relation is specified) a thing must directly hold a thing it conceals, and things cannot conceal things they do not enclose, but âRule for deciding the concealed possessions of Mr Darcy when Mr Darcy encloses the particular possessionâŚâ still leads to the anomaly)
The simplest way round this potential anomaly is either to always work with the âconcealedâ adjective, or to ensure that rules for deciding the concealed possessions of something can only report a positive decision if the âparticular possessionâ is actually directly held by the âconcealerâ under consideration. A good way to enforce this restriction is to include it in the opening declaration of the rule, e.g. âRule for deciding the concealed possessions of a person (called the concealer) who holds the particular possession when the concealer is wearing a cloak:â
Indirect concealment Informâs default definition can be counter-intuitive for indirectly held things- a thing is only concealed (adjective) if its direct holder conceals it. Conversely, a person who conceals (verb) a bag may also (in Version 9.3 if no holding requirement is enforced, or in Version 10 if the rule states âwhen (the person) encloses the particular possessionâ) conceal the bagâs contents, but the bag itself does not conceal its contents and the contents are not concealed(adjective). This is probably unintended, since functional concealment is only fully implemented when direct, so it is advisable to arrange things so that all concealed things are directly concealed by their holder. This will ensure that conceals (verb) is always aligned with concealed (adjective) and that concealed things are also functionally concealed in the game world. Indirect concealment is functionally implemented (in that the contents of concealed things are also functionally concealed), even though they are not âconcealedâ (adjective) and ânothing conceals themâ (verb). To test for indirect functional concealment, conditions like âif something concealed enclosesâŚâ or âlist of things enclosed by something concealedâ work.
Useful undocumented phrases. Some useful built-in but undocumented phrases that work with spatial relations, although they donât define new relations:
See Addendum belowâŚ