I want to make an explicit one-way connection going west without creating an explicit back-edge going east. Section 3.3 of the manual gives two ways of creating one-way connections:
(1) Creating an explicit back-edge (which I don’t want):
Foo and bar are rooms. Foo is west of bar. East of bar is nowhere.
(The explicit back-edge is from bar to nowhere.)
(2) Using a “more complicated” room description:
Foo is a room. Bar is a room above foo.
This seems to create a room bar up from foo with no return down from bar. But the example actually complicates syntax since it introduces a new way of saying ‘up from’.
But replacing the second sentence with Bar is a room west of foo. produces code that won’t compile.
I specifically don’t want (1) because I am trying to generate the underlying maze automatically and removing unwanted back-edges to nowhere adds (at minimum) one level of complexity.
For (2), the problem is obvious: there seems to be no prepositional phrase corresponding to west of like above which corresponds to up from. Section 3.26 on directions talks about creating directions, but not about how to create this alternative way of talking about them.
(My guess is that above is connected to up by some definition or rule, but I don’t know where to look either in the documentation or the built-in extensions for this definition or rule.)
Two questions: (a) How do I create an explicit on-way connection in any given direction (other than up or down) without creating a back-edge to nowhere? and (b) Where is this documented (either documentation or built-in code)?
As a side note the second form does work very well, apart from its being restricted to up and down. The following code works as expected:
A netherroom is a kind of room.
Foo and baz are rooms. Bar is a netherroom.
Bar is a room above foo, Bar is a room below baz.
This places bar above foo and below baz with no back-links. Bar is declared as an instance of netherroom, a kind of room, and the directional statements don’t create any conflicts that cause the code to fail to compile. So how do I do the same thing with up replaced by west and down replaced by east?
I think the goal is to do it in one Inform declaration.
The fact that this is even possible is rather surprising. I had to search around before I rediscovered the explanation in section 3.3:
Finally, note that Inform’s assumptions about two-way directions are only applied to simple sentences. When the source text seems to be saying something complicated, Inform takes it as a precise description of what’s wanted.
Unfortunately you’re right that the “more complicated” declaration just doesn’t seem to work for N/S/E/W. I’m not sure what’s going on, but I couldn’t find a way to work around it.
I think you’re stuck with explicitly saying “East of X is nowhere” a lot. This is completely possible; it’s just some extra code.
What I mean by “back-edge to nowhere” is an explicit second statement of the form East of foo is nowhere..
Using graph-theoretic terminology, the single statement Foo is north of bar. produces two labelled directed edges, one (the forward-edge) from foo to bar labelled north and a second one (the implicit backward-edge) from bar to foo labelled south. If I only want the first one, I am required to add a second statement: South of bar is nowhere. That is equivalent to changing the implicit backward edge to a different explicit backward-edge.
This extra baggage can be circumvented if the directions are up and down using the above/below syntax described in Section 3.3. But apparently no such syntax exists for north/south, east/west, northeast/southwest or northwest/southeast direction pairs.
The use of nowhere creates a complexity problem. If later on I have a room baz that I want to link south of bar, I would say South of bar is baz. But that conflicts with South of bar is nowhere.. This complexity problem is avoidable with up/down connections, even though it requires the use of new words (‘above’ or ‘below’).
I found a solution! I was looking for the definitions of ‘above’ and ‘below’ in the standard rules extension. For example: above is defined as The verb to be above means the reversed mapping up relation.
With the help of the ‘above’ example in Section 3.3, the solution is simple:
Chapter 1 Definitions
The verb to be westward from means the reversed mapping west relation.
Chapter 2 Rooms
Foo and bar are rooms. Foo is a room westward from bar.
The map connections are correct and the extraneous nowhere is nowhere (pun intended) to be found.
When that happens, you can just remove the South of bar is nowhere. Stating the destination explicitly will override the implicit reverse link anyway – that’s essentially the same as what South of bar is nowhere. is doing.
The problem is that approach requires extra work. (I’m a mathematician: I work very hard to avoid unnecessary work!)
Start with a one-way link from bar to foo.
Foo and bar are rooms. Foo is west of bar. East of bar is nowhere.
Now we want, east of bar to be baz:
Baz is a room. East of bar is baz.
At this the Inform 7 compiler rightly complains about the contradiction. Either I have to manually remove the East of bar is nowhere, an annoyance as I want the code to be correct without manual intervention, or I have to know a priori that East of bar is baz, (an additional piece of information to manage in my generator). This is easy enough with just three rooms and two links, but it’s not so easy with perhaps a dozen rooms and 30 or 40 links.
Not quite. It requires avoiding doing the extra work in the first place.
This is where you went wrong. Instead of adding East of bar is baz. here, you simply don’t write that line at all, and edit the line above so that it says baz instead of nowhere. Now the compiler is happy and you didn’t do any extra work.
(Inform doesn’t mind that you haven’t introduced what baz is yet, it will figure it out later. While not quite universal, to a large extent you can define things in any order, they don’t have to be defined before they’re used.)
well, aside that one-way rooms in 2020s should have solid narrative reasons, there’s a cognate case, the winding directions so often found in EU parks and gardens. I think that is best handled with introducing a new token, winding, whose mean “this connection has a non-standard reciprocal” e.g
“the garden path is a room. winding east is the gazebo”.
The verb to be winding east from means the reversed mapping east relation.
The garden path is a room. The gazebo is a room winding east from the garden path.
Though his eastward is more succinct.
Oddly, if you replace is a room winding with just is winding then you get a two-way connection, and this sort of thing doesn’t seem to work with the standard east mapping relation, only with a custom-defined relation like the above. (It works with both reversed and normal relations, but the way you need to phrase it only really makes sense for reversed relations.)
Personally, though, I’d rather just write the is nowhere or otherwise explicitly. Otherwise I’d worry that whatever quirk of the compiler that causes this interpretation might change later and the other exits would “fill in” after an upgrade.
Documented probably needs qualification. Here is my take.
It’s only hinted at in Section 3.3 and I did have to lift the definition of above from the Standard Rules extension to solve the problem. The mapping direction relation (as in The verb to be westward from mean the reversed mapping west relation. isn’t mentioned at all in section 3.3. It might be documented elsewhere, but in any case it seems to be a fundamental feature. Once to be westward from has been defined like above and below, it can be used in the documented manner to produce one-way and two-way connections.
traversing a network of roads by vehicle, The rooms are intersections and points of interest. (Many downtown areas are dense with one-way streets.)
traversing an international airport on foot. With customs and with current security procedures, there are a number of one-way connections.
The Ohio State University campus area in Columbus, Ohio, on foot, just after a football game ends, with walls of people effectively making most passages one-way. (Not likely this year with COVID, but I experienced this first-hand years ago when trying return home on foot from a bookstore - the game let out just before I arrived in the campus area! Manhattan at lunchtime is a tiny village in comparison!)