Question about relations

Hi, I’m stuck again.

I’ve been trying to make a simple market setup, but the following code keeps bugging on me. :frowning:


A shop owner is a kind of person.
The printed name of a shop owner is "[merchandise sold by the shop owner] shop owner".

A merchandise is a kind of thing.

Selling relates a shop owner to a merchandise.

The verb to sell (he sells, they sell, he sold, he is selling, he has sold) implies the selling relation.

The verb to be sold by implies the reversed selling relation.

A fruit is a kind of merchandise.

Marek is a shop owner in Market.
Marek sells fruit.

Apparently, [merchandise sold by the shop owner] is a description of merchandises (whatever that actually means) and it describes items too vaguely and therefore cannot be said.

Not bad. Your code was essentially correct. The basic problem is pretty common, and stems from the fact that Inform 7 (at least at the moment of writing) fails to infer that the possible merchandises sold by a shop are one and only one at any given time.

Therefore, we add “a random” before “merchandise.” It looks sort of silly, but that’s how it works. I suspect the reason is that in your code I7 tries to look for a thing named “a merchandise,” rather than a thing of the merchandise kind.

A shop owner is a kind of person.
The printed name of a shop owner is "[a random merchandise sold by the shop owner] shop owner".

A merchandise is a kind of thing.

Selling relates a shop owner to a merchandise.

The verb to sell (he sells, they sell, he sold, he is selling, he has sold) implies the selling relation.

The verb to be sold by implies the reversed selling relation.

A fruit is a kind of merchandise.

The Market is a room.
Marek is a shop owner in Market.
Marek sells fruit.

Great, thanks, that works. Unfortunately, it leads to another problem, since now I can’t refer to the fruit shop owner as the fruit shop owner, since it doesn’t recognise “fruit”, and [merchandise sold by the shop owner] (with or without random) doesn’t seem to be a valid token for Understanding.

Er, no, actually, it doesn’t work. It only works correctly with one shop owner and one merchandise, but with more of either, it goes haywire. I just checked and poor Marek with his apples and bananas is called a weaponry shop owner while Saheem, who sells swords and maces, is a fruit shop owner. I’m thinking it needs some kind of When play begins loop?

Something like

When play begins:
	repeat with X running through shop owners:
		now the printed name of X is "a [merchandise sold by X] shop owner";

except the [merchandise sold by X] seems to be problematic again.

EDIT: And just to be clear, I wasn’t being sarcastic. I truly thought it was working (it just incidentally named the owners correctly, and since I couldn’t examine them to see what they were selling, it looked all right), but then I thought to showme one of them on the next compile and found out about the problem. So, to Eleas: I was really grateful for your quick response.

It’s doable. Well, I’m a bit woozy from meds so it may be I’m not at my best right now. The following code should do the trick, but if you do decide to use it, don’t take my drugged-up word for it as being gospel. :slight_smile:

One thing to remember is that just as you won’t be able to refer to “thing” (as in ‘x thing’) to match every thing in scope, so will the shop owner kind not automatically refer to a shop owner. We need to add that, and then just do a relation-based understand statement.

A shop owner is a kind of person. Understand "shop owner" or "seller" or "merchant" as a shop owner.

After printing the name of a shop owner (called subject): say " ([the random merchandise sold by subject] shop owner)".

A merchandise is a kind of thing.

Selling relates a shop owner to a merchandise.
The verb to sell (he sells, they sell, he sold, he is selling, he has sold) implies the selling relation.

The verb to be sold by implies the reversed selling relation.

Understand "[something related by selling]" as person. 

A fruit is a kind of merchandise.
A tool is a kind of merchandise.

The Market is a room.
Marek is a shop owner in the Market.
John is a shop owner in the Market.
Marek sells fruit.
John sells tools.

Now it works perfectly. Thanks.

The printed name of a shop owner is "[a random merchandise sold by the shop owner] shop owner".

The right way to do the above:

The printed name of a shop owner is "[a random merchandise sold by the item described] shop owner".