Can relation properties be defined in assertions?

Note: This question is more of a curiosity than something I’d use in my game (unless the answer actually turns out to be “yes”).

I recently saw Zed’s mixmaster example, and a little later I noticed that there’s a default response to examining directions, so I decided I’d like to replace that default response in some rooms.

There are obvious, relatively simple ways to do this, like an Instead of examining west in the Atrium for every case or maybe something like A room has some text called the west-view for each of the possible directions.

But thanks to the aforementioned example, I came up with this possibly crazy approach:

Messy Restaurant is a room. "It's a huge mess, with broken plates and food everywhere. There must've been a big fight here recently."

A room has a relation of direction to text called viewpoint.

When play begins:
	now the viewpoint of Messy Restaurant relates west to "You see some spaghetti over there.";
	now the viewpoint of Messy Restaurant relates south to "Several cream pies are splattered all over the wall.";
	now the viewpoint of Messy Restaurant relates up to "Gravy drips from the otherwise immaculate chandelier.";
	now the viewpoint of Messy Restaurant relates outside to "The windows are streaked with mustard.".

Carry out examining a direction when the noun relates to a text by the viewpoint of the location:
	say "[the text to which the noun relates by the viewpoint of the location][line break]" instead.

It totally works, but I was wondering if there was any way to set up those relations as static assertions rather than in begin play.

  • I tried just using the same statement that was placed in now, but the compiler thought I was trying to define a relation rather than specify one.
  • I tried adding The verb to correspond means the universal relation and using corresponds instead of relates, but that didn’t work either (I probably misunderstood what the “universal relation” actually is).
  • I also tried The verb to overlook means the viewpoint property, which (perhaps unsurprisingly) didn’t work, as it wanted me to write “<room> overlooks <relation>” which doesn’t seem to work for this purpose.

This does work:

The verb to overlook means the viewpoint property.
Zooming relates various directions to various text.
The verb to zoom means the zooming relation.
Messy Restaurant overlooks the zooming relation.

West zooms "You see some spaghetti over there.".
South zooms "Several cream pies are splattered all over the wall.".
Up zooms "Gravy drips from the otherwise immaculate chandelier.".
Outside zooms "The windows are streaked with mustard.".

But it obviously defeats the point of doing this if I have to define a separate relation and verb for every room using the feature.

This kind of situation already works for directions, so in theory I would think there was a way to do it… but then again, directions are presumably handled specially, so there’s no reason to expect anything that works on them to also work on a relation property.

The goal would be to be able to write statements like this:

West of Messy Restaurant resembles "You see some spaghetti over there.".

Side note: I do realize that (as shown in the mixmaster example) the when play begins rules can also be made a little more palatable (even matching the above non-working assertion) with a phrase:

To (D - a direction) of (R - a room) resembles (T - a text):
	now the viewpoint of R relates D to T.

When play begins:
	west of Messy Restaurant resembles "You see some spaghetti over there.";
	south of Messy Restaurant resembles "Several cream pies are splattered all over the wall.";
	up of Messy Restaurant resembles "Gravy drips from the otherwise immaculate chandelier.";
	outside of Messy Restaurant resembles "The windows are streaked with mustard.".

As noted at the top of the post, I probably won’t end up using this approach. I’m currently thinking of settling on the middle-ground of defining 4 or 6 properties for a room (the west-view, south-view, etc – I don’t expect to need this for inside and outside). But I’m still curious if there’s any palatable way for the relation approach to be set up statically… or if there’s any interest in adding a way to do this.

1 Like

No. As you’ve noted, you’d need a different verb per room to make it work.

I doubt there’d be much interest in implementing this given how straightforward the workaround is.

1 Like

Which are you considering to be the workaround?

  • One relation+verb per room
  • Setting it up when play begins

The latter!

I suppose that’s fair enough. It certainly is fairly straightforward, though it lacks a certain, shall we say, “elegance”.

if it makes you feel any better…

Assert is a nothing based rulebook.
Last after starting the virtual machine: follow the assert rules.

Assert: west of Messy Restaurant resembles "You see some spaghetti over there.";
  [etc.]
3 Likes

I just thought of another possibly crazy way to get a similar effect.

Messy Restaurant is a room. "It's a huge mess, with broken plates and food everywhere. There must've been a big fight here recently."

A viewpoint is a kind of value. A viewpoint has a direction called look-dir. A viewpoint has some text called description.

Viewing-towards relates one room to various viewpoints.
The verb to resemble means the viewing-towards relation.

Messy Restaurant resembles a viewpoint with look-dir west and description "You see some spaghetti to over there.".
Messy Restaurant resembles a viewpoint with look-dir south and description "Several cream pies are splattered all over the wall.".
Messy Restaurant resembles a viewpoint with look-dir up and description "Gravy drips from the otherwise immaculate chandelier.".
Messy Restaurant resembles a viewpoint with look-dir outside and description "The windows are streaked with mustard.".

Definition: a direction (called thataway) is interesting:
	unless the location resembles a viewpoint, no;
	let candidates be the list of viewpoints resembled by the location;
	repeat with V running through candidates:
		if the look-dir of V is thataway, yes;
	no.

Carry out examining an interesting direction:
	let candidates be the list of viewpoints resembled by the location;
	repeat with V running through candidates:
		if the look-dir of V is the noun:
			say "[description of V][line break]" instead.

It admittedly still has some issues (in particular, could looping over these things on every look be a performance issue), and the choice of words (mainly “viewpoint” and “resembles”) may have room for improvement, but it does allow for static assertions! If you don’t like “look-dir” you can omit the called look-dir part and then write with direction west.

Or if you preferred you could also write the assertions like this:

The verb to view means the look-dir property.

Messy Restaurant resembles spaghetti-view, cream-pie-view, gravy-view, and mustard-view.
Spaghetti-view views west. "You see some spaghetti to over there.".
Cream-pie-view views south. "Several cream pies are splattered all over the wall.".
Gravy-view views up. "Gravy drips from the otherwise immaculate chandelier.".
Mustard-view views outside. "The windows are streaked with mustard.".

Again there’s possibly room for improvement in the choice of verb, but it certainly functions.

2 Likes

Very nice!

Unless you have hundreds of rooms, I greatly doubt it. But I’ll note that you don’t need to make the list, and list-making is slow enough to be worth avoid doing it gratuitously.

Carry out examining an interesting direction:
	repeat with V running through viewpoints resembled by the location:
		if the look-dir of V is the noun:
			say "[description of V][line break]" instead.

But like I said, even with list-making, you’d probably be fine if you didn’t have an outlandish number of rooms.

Ah, good point. The reason I did a list is because I started out using the “list of (kind) that relate to (value) by (relation)” phrase, which apparently doesn’t work in this context.

The actual code and error message, for those interested
Definition: a direction (called thataway) is interesting:
	unless the location resembles a viewpoint, no;
	repeat with V running through the list of viewpoints that relate to the location by the viewing-towards relation:
		if  V views thataway, yes;
	no.

It produces the following error:

Problem. In ‘repeat with V running through the list of viewpoints that relate to the location by the viewing-towards relation’, the phrase ‘list of viewpoints that relate to the location by the viewing-towards relation’ doesn’t seem to fit: I was hoping it would be a description of values, but in fact it’s a list of viewpoints.

I was trying to match one of these phrases:

  1. list of (viewpoints - name of kind) that/which/whorelate to (location - value) by (viewing-towards relation - relation of values) :x:
  2. list of (viewpoints that relate to the location by the viewing-towards relation - description of values) :x:

I recognised:

viewpoints = a description of viewpoints
location = a non-temporary variable, holding an object
viewing-towards relation = a relation of rooms to viewpoints

But I didn’t recognise ‘viewpoints that relate to the location by the viewing-towards relation’.

And factoring the list out into a variable didn’t help either:

Problem. You wrote ‘let candidates be the list of viewpoints that relate to the location by the viewing-towards relation’: but the ingredients in this phrase do not fit it, and I am confused enough by this that I can’t give a very helpful problem message. Sorry about that.

I was trying to match one of these phrases:

  1. list of (viewpoints - name of kind) that/which/whorelate to (location - value) by (viewing-towards relation - relation of values) :x:
  2. list of (viewpoints that relate to the location by the viewing-towards relation - description of values) :x:

I recognised:

viewpoints = a description of viewpoints
location = a non-temporary variable, holding an object
viewing-towards relation = a relation of rooms to viewpoints

But I didn’t recognise ‘viewpoints that relate to the location by the viewing-towards relation’.

Then later on I realized that the relation has a verb and I can just use it; and after that I never thought to avoid using a list.

I would like to know how many rooms starts to qualify as outlandish though…

For your use case? Tables!

Strangely enough, I do have a table related to this (it determines when the backdrops are in the room where they’re transient).

Incidentally, I tried eliminating the explicit loop, but both of the following conditions result in an error message that says it’s trying to treat a viewpoint as an object (with or without the parentheses):

if thataway is viewed by (a viewpoint resembled by the location):
if (a viewpoint resembled by the location) views thataway:

It doesn’t really matter that much though, since this condition is squirrelled away into the internals.

1 Like

You have to watch the details of the automatic verb construction and the left/right membership of the relation with respect to it. In this case, the “list of values” the compiler wants is the right member of the relation, which it assumes it wants because of the active voice of the verb to resemble.

This approach works (in 9.3/6M62) with:

The verb to view means the look-dir property.

Definition: a direction (called thataway) is interesting:
	unless the location resembles a viewpoint, no;
	repeat with V running through viewpoints resembled by the location:
		if  V views thataway, yes;
	no.

It seems like it should be possible to wrap up the definition in something more compact (i.e. let the I7 compiler write the loop-check), but I can’t figure out an acceptable syntax, and I think there may be some bugs in the compiler’s interpretation of conditions here.

Specifically, the statements:

let VV be the list of viewpoints that view thataway;

or

let VV be the list of viewpoints viewing thataway;

where thataway is a direction produce error messages suggesting that it is trying to interpret that as intended to produce a list of texts (in 9.3/6M62) or a list of nothing (10.1.2). Some issue specific to property-defining verbs, maybe?

1 Like

Yeah, that’s what I thought too, but I couldn’t find a way to make it work. I didn’t consider the possibility that it might be a compiler bug though.

Actually, looking in detail at the generated I6 for the example under 6M62, I think that at least part of the problem is a name clash with the built-in adaptive text viewpoint.

This seems to work (at least in 6M62):

Messy Restaurant is a room. "It's a huge mess, with broken plates and food everywhere. There must've been a big fight here recently."

A vista is a kind of value.
A vista has a direction called viewing direction. The verb to supply a vantage to means the viewing direction property.
A vista has some text called description.

Vantage relates one room (called vantage point) to various vistas.
The verb to overlook means the vantage relation.

Messy Restaurant overlooks a vista with viewing direction west and description "You see some spaghetti to over there.".
Messy Restaurant overlooks a vista with viewing direction south and description "Several cream pies are splattered all over the wall.".
Messy Restaurant overlooks a vista with viewing direction up and description "Gravy drips from the otherwise immaculate chandelier.".
Messy Restaurant overlooks a vista with viewing direction outside and description "The windows are streaked with mustard.".

Definition: A vista is scanned if it supplies a vantage to the noun and the location overlooks it.
Definition: A direction (called D) is scenic if there is a scanned vista (called V) overlooked by the location and V supplies a vantage to D.

Carry out examining a scenic direction (called D):
	say "[description of a random scanned vista][line break]" instead.
2 Likes