[I7] Referring to nonexistent but possible things

I want the player to be able to refer to nonexistent but possible things. An example will show my meaning better.

[code]Temperature is a kind of value. The temperatures are hot and cold.

A thing has a temperature. Understand the temperature property as referring to a thing.

Temperature Lab is a room. “The perfect place to HEAT or COOL things!”

The very mysterious substance is a cold thing, here. The description of the substance is “Very mysterious and [temperature].”

Heating is an action applying to one thing. Understand “heat [thing]” as heating.

Carry out heating: now the noun is hot.

Report heating: say “You heat [the noun].”

Cooling is an action applying to one thing. Understand “cool [thing]” as cooling.

Carry out cooling: now the noun is cold.

Report cooling: say “You cool [the noun].”.

Pondering is an action applying to one visible thing. Understand “ponder [any thing]” as pondering.

Report pondering: say “You ponder [the noun].”

Considering is an action applying to one temperature and one visible thing. Understand “consider [temperature] [any thing]” as considering.

Report considering: say “You consider [the second noun], which is [temperature understood].”[/code]
In this example, I have a substance with a temperature. I can say TAKE COLD SUBSTANCE when it is cold, but not when it is hot, and vice versa. This I expect and it is not the problem.

Then I have pondering. I want PONDER COLD SUBSTANCE to always work, but it fails if the substance is hot. How can I make it always work?

A solution like considering (see code) is not ideal, because I would like to be able to do this with an arbitrary number of adjectives in any order, like PONDER TEPID STICKY VISCOUS GREEN SUBSTANCE.

If I understand Inform right, this problem happens because the parser is equipped to only look for things that do exist, not things that could exist. I have looked at Parser.i6t to see if I could mess around with it but I really don’t know what I’m doing, so I didn’t.

Does this do what you want?

To decide what action-name is the action-to-be: (- action_to_be -).
Understand "[temperature]" as a thing when the action-to-be is the pondering action.

I tried something fancier that would allow you to restrict the range of temperatures avaliable (so that if the substance was possibly hot or possibly warm but not possibly cold, you could make it so that only hot and warm would work), but it produced an internal error. Actually it would probably be better to have that be understood but give a message along the line of “The substance could never be cold!”

That does not work. The parser accepts the input, but if I change the report of pondering to say “You ponder [the noun], which is [temperature of the noun].” and I input PONDER HOT SUBSTANCE when it is cold, it prints “You ponder the very mysterious substance, which is cold.”

I want the game, given PONDER HOT SUBSTANCE, to print “You ponder the very mysterious substance, which is hot.”

EDIT:
Here is a more fleshed out example:
[rant][code]Section - New Kinds

A substance is a kind of thing.

Temperature is a kind of value. The temperatures are hot and cold. A substance has a temperature. A substance is usually cold. Understand the temperature property as referring to a substance.

Humidity is a kind of value. The humidities are dry and moist. A substance has a humidity. A substance is usually dry. Understand the humidity property as referring to a substance.

Section - Setting

The Laboratory is a room. “A perfect place to practice pondering.”

The lump of slag is a substance, here. The description of the slag is “It is cold, dry, and worthless.”

Section - Pondering

Pondering is an action applying to one visible thing. Understand “ponder [any thing]” as pondering.

Report pondering:
if the noun is hot begin;
if the noun is dry begin;
say “Fire.”;
otherwise;
say “Air.”;
end if;
otherwise;
if the noun is dry begin;
say “Earth.”;
otherwise;
say “Water.”;
end if;
end if.

To decide what action-name is the action-to-be: (- action_to_be -).

Understand “[humidity]” as a substance when the action-to-be is the pondering action.

[Understand “[temperature]” as a substance when the action-to-be is the pondering action.] [Inform will only accept one of these two lines at a time.][/code][/rant]

Here is what I want:

Here is what I get:

This happens because any humidity is understood as referring to a substance when pondering, and the only substance there is the slag, which is cold and dry (earth).

Hm. Well, the “action-to-be” business exhausts my knowledge of how to get stuff out of the parser internals, so I don’t know whether it’s possible to figure out whether the player input “hot substance” or “cold substance” given my code.

For the behavior in your ranted example, would it help to have some archetypes of the various possibilities in some inaccessible room? This gets you part of the way, but you’ll have to decide how to disambiguate when the player types “ponder hot.” Also, it seems to me that if you want “ponder hot” to work you need to say “Understand the temperature property as describing a substance”; if you have “referring to” it’ll require you to add “substance” or some other name.

[rant][code]“Forms and Things”

Section - New Kinds

A substance is a kind of thing. Understand “substance” as a substance.

Temperature is a kind of value. The temperatures are hot and cold. A substance has a temperature. A substance is usually cold. Understand the temperature property as describing a substance.

Humidity is a kind of value. The humidities are dry and moist. A substance has a humidity. A substance is usually dry. Understand the humidity property as describing a substance.

Section - Setting

The Laboratory is a room. “A perfect place to practice pondering.”

The lump of slag is a substance, here. The description of the slag is “It is cold, dry, and worthless.”

Section - Archetypes

The Formitorium is a room.
Earth is a substance in Formitorium. Earth is cold and dry.
Air is a substance in Formitorium. Air is hot and moist.
Water is a substance in Formitorium. Water is cold and moist.
Fire is a substance in Formitorium. Fire is hot and dry.

Section - Pondering

Pondering is an action applying to one visible thing. Understand “ponder [any thing]” as pondering.

Report pondering:
if the noun is hot begin;
if the noun is dry begin;
say “Fire.”;
otherwise;
say “Air.”;
end if;
otherwise;
if the noun is dry begin;
say “Earth.”;
otherwise;
say “Water.”;
end if;
end if.

To decide what action-name is the action-to-be: (- action_to_be -).

After deciding the scope of the player when the action-to-be is the pondering action:
place the contents of the Formitorium in scope.
[/code][/rant]

This works, for this short example with temperature and humidity. But what if I wanted ten such variables? Twenty? There must be a better way to do this than creating thousands of objects hidden away in a secret room.

If Inform 7 were the perfect language, I would code something like “Understand “ponder [list of adjectives] [any thing]” as a pondering a thing.” and then refer to the list of adjectives understood or something like that. But alas! I cannot.

I have been poking around the page of I7 extensions and I saw one called Dynamic Objects. Could I use that to parse the player’s command, then create an object customized to the player’s input? If so, how?

Well, if you don’t mind you can mess around with the player’s command directly. This will become very annoying if you have a lot of synonyms for your adjectives, but it’s probably the best I can do now. (Someone else may well be able to do better.)

[rant][code]“Forms and Things”

Section - New Kinds

A substance is a kind of thing. Understand “substance” as a substance.

Temperature is a kind of value. The temperatures are hot and cold. A substance has a temperature. A substance is usually cold.
Humidity is a kind of value. The humidities are dry and moist. A substance has a humidity. A substance is usually dry.

Section - Setting

The Laboratory is a room. “A perfect place to practice pondering.”

The lump of slag is a substance, here. The description of the slag is “It is cold, dry, and worthless.”
The glob of mud is a substance, here. The glob of mud has humidity moist.

Section - Temperature-Settings

The temperature-in-question is a temperature that varies. Temperature-changed is a truth-state that varies.
The humidity-in-question is a humidity that varies. Humidity-changed is a truth-state that varies.

After reading a command when the player’s command includes “ponder”:
now temperature-changed is false;
now humidity-changed is false;
if the player’s command includes “hot” and the player’s command includes “cold”:
say “You’re blowing hot and cold!”;
reject the player’s command;
otherwise if the player’s command includes “hot”:
now the temperature-in-question is hot;
cut the matched text;
now temperature-changed is true;
otherwise if the player’s command includes “cold”:
now the temperature-in-question is cold;
cut the matched text;
now temperature-changed is true;
if the player’s command includes “moist” and the player’s command includes “dry”:
say “You can’t be both moist and dry.”;
reject the player’s command;
otherwise if the player’s command includes “moist”:
now the humidity-in-question is moist;
now humidity-changed is true;
cut the matched text;
otherwise if the player’s command includes “dry”:
now the humidity-in-question is dry;
cut the matched text;
now humidity-changed is true;
let T be indexed text;
let T be the player’s command;
change the text of the player’s command to “[T] substance”. [in case we’ve removed everything but ‘ponder’, we add “substance” in so there’s an available noun]

Section - Pondering

Pondering is an action applying to one visible thing. Understand “ponder [any thing]” as pondering.
Report pondering:
unless temperature-changed is true:
now the temperature-in-question is the temperature of the noun;
unless humidity-changed is true:
now the humidity-in-question is the humidity of the noun;
if the temperature-in-question is hot:
if the humidity-in-question is dry:
say “Fire.”;
otherwise:
say “Air.”;
otherwise:
if the humidity-in-question is dry:
say “Earth.”;
otherwise:
say “Water.”

[If there is more than one substance present and the player specified pondering a specific adjective, we want to default to pondering the one that matches]
Does the player mean pondering a hot substance when temperature-changed is true and the temperature-in-question is hot: it is likely.
Does the player mean pondering a cold substance when temperature-changed is true and the temperature-in-question is cold: it is likely.
Does the player mean pondering a moist substance when humidity-changed is true and the humidity-in-question is moist: it is likely.
Does the player mean pondering a dry substance when humidity-changed is true and the humidity-in-question is dry: it is likely.
[/code][/rant]

I don’t know that “Dynamic Objects” would do what you want – you could just as well create a dummy object in an offstage room and change its properties as you like.

For what it’s worth, the bug I reported with “something related by reversed possibilizing” seems to have been upgraded from mild to critical, indicating that the thing I was doing there was supposed to work. Maybe if that gets fixed it’ll help with your problem.

By the way, if you want to cut down the amount of typing you have to do for my solution, you might be able to make some tables with the text you want – so you have a table with the texts “moist,” “wet,” “damp” and any other synonyms you like, all associated with the humidity moist, and in the “after reading a command” rule you loop through that table to extract any synonyms that may be there.

I’m glad to hear of the acknowledgement of the bug. I wrote this last night:

[rant][code]“Forms and Things”

Section - New Stuff

A substance is a kind of thing. Understand “substance” as a substance.

Adjective is a kind of value. Some adjectives are defined by the Table of Adjectives.
[N.B. Adjectives are never used themselves. Just their word and domain entries are. I left them in case they ever are needed.]

Table of Adjectives
adjective [tab] word (indexed text) [tab] domain
cold [tab] “cold” [tab] “temperature”
hot [tab] “hot” [tab] “temperature”
dry [tab] “dry” [tab] “humidity”
moist [tab] “moist” [tab] “humidity”

The adjective stack is a list of indexed texts which varies.

The domain stack is a list of texts which varies.

Section - Setting

The Laboratory is a room. “A perfect place to practice pondering.”

The lump of slag is a substance, here.

The glob of mud is a substance, here.

Section - Pondering

Pondering is an action applying to one topic. Understand “ponder [text]” as pondering. Pondering is irrealis behavior.

Before irrealis behavior:
now the adjective stack is {};
now the domain stack is {};
let T be indexed text;
let T be the topic understood;
repeat with i running from 1 to the number of words in T begin;
let W be word number i in T;
if W is listed in the adjective stack, next;
repeat through the Table of Adjectives begin;
if the word entry exactly matches the text W begin;
let D be the domain entry;
if D is listed in the domain stack begin;
say “You may only specify one [D].”;
stop the action;
otherwise;
add D to the domain stack;
end if;
break;
end if;
end repeat;
add W to the adjective stack;
end repeat.

Report pondering:
[say “[adjective stack in brace notation][line break]”;]
if “cold” is listed in the adjective stack begin;
if “dry” is listed in the adjective stack begin;
say “Earth.”;
otherwise if “moist” is listed in the adjective stack;
say “Water.”;
otherwise;
say “Pure cold.”;
end if;
otherwise if “hot” is listed in the adjective stack;
if “dry” is listed in the adjective stack begin;
say “Fire.”;
otherwise if “moist” is listed in the adjective stack;
say “Air.”;
otherwise;
say “Pure heat.”;
end if;
otherwise;
if “dry” is listed in the adjective stack begin;
say “Pure aridity.”;
otherwise if “moist” is listed in the adjective stack;
say “Pure humidity.”;
otherwise;
say “There is nothing to ponder.”;
end if;
end if.[/code][/rant]

Is this efficient? It works fine now, but how fast is table look-up when the table has e.g. 100 rows?

I didn’t do synonyms in this code but it shouldn’t be hard to add them.

I’m very much non-expert on this, but I’m told table access is fast.

Anyway, your code looks it does some very nice adjective extracting. One potential issue is that it doesn’t involve direct reference to substances anymore (the slag isn’t doing anything, it seems), though that might be what you want. Another thing is that it completely ignores irrelevant words, so that “ponder hot moist throbbing quivering jello” gives you “Air.”

But hey, at this point you’re better at this than I am.

The parser now accepts only adjectives and nouns it knows. It also supports synonyms. As long as it doesn’t get slow, I think this approach is acceptable, though I would prefer not writing needing to specify an indexed text version of every adjective.

[rant][code]“Forms and Things”

Section - New Stuff

Adjective is a kind of value. Some adjectives are defined by the Table of Adjectives.
[N.B. Adjectives are never used for any objects in this example. I left them in case they ever are needed.]

Table of Adjectives
adjective [tab] domain
cold [tab] “temperature”
hot [tab] “temperature”
dry [tab] “humidity”
moist [tab] “humidity”

Table of Adjective Words
word (indexed text) [tab] adjective
“cold” [tab] cold
“hot” [tab] hot
“dry” [tab] dry
“moist” [tab] moist
“wet” [tab] moist [a synonym]

The adjective stack is a list of adjectives which varies.

The domain stack is a list of texts which varies.

The archetype is an object which varies.

Section - Setting

The Sophists’ Lounge is a room. “A perfect place to practice pondering.”

Section - Archetypes

The Archetype Case is a room. A humor is here. An element is here.

Section - Pondering

Pondering is an action applying to one topic. Understand “ponder [text]” as pondering. Pondering is irrealis behavior.

Before irrealis behavior:
now the adjective stack is {};
now the domain stack is {};
now the archetype is nothing;
let T be the topic understood;
let N be the number of words in T;
repeat with i running from 1 to N - 1 begin;
let W be word number i in T;
let A be an adjective;
if there is an adjective corresponding to a word of W in the Table of Adjective Words, let A be the adjective corresponding to a word of W in the Table of Adjective Words;
unless there is an adjective of A in the Table of Adjectives begin;
say “I do not know the adjective ‘[W].’”;
stop the action;
end unless;
if A is listed in the adjective stack, next;
if there is a domain corresponding to an adjective of A in the Table of Adjectives begin;
let D be the domain corresponding to an adjective of A in the Table of Adjectives;
if D is listed in the domain stack begin;
say “You may only specify one [D].”;
stop the action;
otherwise;
add D to the domain stack;
end if;
end if;
add A to the adjective stack;
end repeat;
let W be indexed text;
let W be word number N in T;
repeat with item running through objects in the Archetype Case begin;
if W exactly matches the text “[item]” begin;
now the archetype is the item;
break;
end if;
end repeat;
if archetype is nothing begin;
say “I do not know what this so-called ‘[W]’ is.”;
stop the action;
end if.

Report pondering:
[say “[adjective stack in brace notation][line break]”;]
if cold is listed in the adjective stack begin;
if dry is listed in the adjective stack begin;
if the archetype is an element begin;
say “Earth.”;
otherwise if the archetype is a humor;
say “Black bile.”;
otherwise;
say “Cold and dry.”;
end if;
otherwise if moist is listed in the adjective stack;
if the archetype is an element begin;
say “Water.”;
otherwise if the archetype is a humor;
say “Phlegm.”;
otherwise;
say “Cold and moist.”;
end if;
otherwise;
say “Pure cold.”;
end if;
otherwise if hot is listed in the adjective stack;
if dry is listed in the adjective stack begin;
if the archetype is an element begin;
say “Fire.”;
otherwise if the archetype is a humor;
say “Yellow bile.”;
otherwise;
say “Hot and dry.”;
end if;
otherwise if moist is listed in the adjective stack;
if the archetype is an element begin;
say “Air.”;
otherwise if the archetype is a humor;
say “Blood.”;
otherwise;
say “Hot and moist.”;
end if;
otherwise;
say “Pure heat.”;
end if;
otherwise;
if dry is listed in the adjective stack begin;
say “Pure aridity.”;
otherwise if moist is listed in the adjective stack;
say “Pure humidity.”;
otherwise if the archetype is an element;
say “Elementary.”;
otherwise if the archetype is a humor;
say “Humorous.”;
otherwise if the archetype is nothing;
say “[The archetype] is not worth pondering.”;
end if;
end if.[/code][/rant]

I guess I just needed some help getting started. Thanks for your catalysis!