Handling I didn't understand that sentence in a newbie-friendly way

Hi all,

Fighting with Inform once more. I am currently adding custom verbs and am trying to make it more newbie-friendly but not sure what is the best approach here. Here is a simplified scenario:

Basically I create things with properties. I can refer to these things by their properties, that works just fine. However when trying to create a command to refer to a thing and a property, I am at a loss as on how to do the error handling. Reading the SR on e.g. the ‘inserting it into’ verb did not really enlighten me in how incomplete input can be properly handled…

Transformers
An Interactive Fiction
Release 1 / Serial number 230406 / Inform 7 v10.1.0 / D
 
Laboratory
Many devious experiments are conducted here.
 
You can see a red car, a green airplane and a blue robot here.
 
>transform red car into a robot
You have transformed the red car into a red robot.
 
>transform red car into a robot
I didn't understand that sentence.
 
>look
Laboratory
Many devious experiments are conducted here.
 
You can see a red robot, a green airplane and a blue robot here.
 
>transform green airplane
I didn't understand that sentence.
 
>transform green airplane into
I didn't understand that sentence.

The I didn't understand that sentence is not very helpful to a newbie player I’d think.

Any feedback is very much appreciated!

3 Likes

So I think what’s happening here is that in the second “transform red car into robot” command it’s matching “red” as the noun – like, the just-transformed red robot – so that the command is parsed as TRANSFORM [RED] CAR INTO [ROBOT], and of course that isn’t grammar it knows what to do with.

This is a bit hacky and I don’t have time to test it, but you might be able to work around it by changing the action grammar?

Understand “transform red/green/blue/-- [something] into a/an/-- [shape]” as transforming it into.

That leads to:

>transform red car into robot
You have transformed the red car into a red robot.

>transform red car into robot
You can't see any such thing.

(Might be unintended consequences, this is 2 minutes of thinking and all I have time for, sorry!)

My general solution is to also recognize the lines “transform [text] into a/an/-- [shape]” (“You don’t have a [topic understood] at the moment.”) and “transform [something] into a/an/-- [text]” (“A [topic understood] isn’t a shape you know.”).

In other words, make your own error messages, because you’re smarter than the parser is!

2 Likes

You can also understand the color property as referring to a transformer, instead of describing it, which means the parser considers RED ROBOT to refer to a transformer but not RED on its own.

I’ve always felt these were backward, because “describing” sounds like it should apply to adjectives and “referring to” should apply to nouns. But that’s the way it is. (See WI §17.15 for details.)

3 Likes

An easy way to do this is to add the line:

Understand "transform [something] into [text]" as a mistake ("You must transform that into a car, an airplane, or a robot.")

This defines a new grammar line which is broader ([text] matches anything at all) but lower precedence (so it won’t interfere with the original shape-matching line).

2 Likes

I was assuming you mean to write these as

Understand "transform [text] into a/an/-- [shape]" as a mistake ("You don’t have a [topic understood] at the moment.").

Inform7 docs tell me it is not safe to use markers…

>transform blah into robot
You don't have a 
*** Run-time problem P39: Attempt to say a snippet value which is currently invalid: words 0 to 2.
 
 at the moment.

Ah, right, I forgot that parsing [shape] overwrites the topic understood (they’re stored in the same variable). Change the error message to “You don’t have one of those at the moment.” or something like that.

1 Like

No, I wrote what I tested. The first parameter is an object ([something]) so that the parser can do regular object disambiguation on it.

If you type TRANSFORM DSFJGDFGD INTO DGFDG it’ll say “You can’t see any such thing”, but that’s true of any verb.

EDIT: Or maybe you were responding to Daniel, okay.

This works pretty much as I’d expect, and gives a much clearer error message:

>transform red car into a robot
You have transformed the red car into a red robot.
 
>transform red car into a robot
You can't see any such thing.

This covers the bases I thought of… Borogove link

lab is a room. "Many devious experiments are conducted here."

Colour is a kind of value. The colours are red, green, and blue.

A transformer is a kind of thing.
a transformer is usually privately-named.
a transformer has a colour.
A transformer-bot is a kind of transformer.
a transformer-disguise is a kind of transformer.

Transformation relates one transformer-disguise to one transformer-bot.
The verb to transform into means the transformation relation.
The verb to be transformed into by means the reversed transformation relation.

Understand the colour property as describing a transformer.

a car is a kind of transformer-disguise. Understand "car" as a car.
an airplane is a kind of transformer-disguise. understand "airplane" as an airplane.
a robot is a kind of transformer-bot. understand "robot" as a robot.
The printed name of a car is usually "[the colour of the item described] car".
The printed name of an airplane is usually "[the colour of the item described] airplane".
The printed name of a robot is usually "[the colour of the item described] robot".

Every transformer-disguise transforms into a robot (called its bot).
a transformer-bot has a transformer-disguise called disguise.

the red-car is a red car.
the red-car is in the lab.
the green-airplane is a green airplane.
the green-airplane is in the lab.
the blue-airplane is a blue airplane.
the blue-airplane's bot is in the lab.
The green-car is a thing.

when play begins:
repeat with t-disguise running through transformer-disguises begin;
  let t-bot be a random robot transformed into by t-disguise;
  now the colour of t-bot is the colour of t-disguise;
  now the disguise of the t-bot is the t-disguise;
  if t-disguise is on-stage begin;
    now t-disguise incorporates t-bot;
  else;
    if the bot is on-stage, now t-bot incorporates t-disguise;
  end if;
end repeat;

transforming it into is an action applying to one thing and one visible thing.

Understand "transform [thing] into [thing]" as transforming it into.

monotransforming is an action applying to a thing.
understand "transform [thing]" as monotransforming.
before monotransforming a transformer when the noun incorporates a transformer, instead try transforming the noun into a random thing incorporated by the noun.
before monotransforming a transformer when a transformer incorporates the noun, instead say "But it's already transformed.".
before monotransforming something, instead say "[The noun] [can't] be transformed.".

 before transforming a transformer into when the second noun is the noun, instead say "But that's what it already is.".
before transforming a transformer into when the noun is part of the second noun, instead say "But that's what it already is.".

instead of transforming something into a thing (called the target) when the target is not part of the noun, instead say "[transformation-error][paragraph break]"

does the player mean transforming something (called the transformed) into something (called the target) when the target is part of the transformed: it is very likely.

does the player mean transforming something (called the transformed) into something (called the target) when the transformed is part of the target: it is very likely.

to say transformation-error: say "[regarding the noun][Those] [don't] turn into that.[no line break]".

Understand "transform [thing] into [text]" as a mistake ("[transformation-error][no line break]")

carry out transforming it into:
  now the second noun is in the holder of the noun;
  now the second noun incorporates the noun

report transforming it into:
  say "[The noun] turns into [a second noun]."

before doing anything to a transformer (called the wossname) when the wossname is a part of a thing: [instead carry out the issuing the response text activity with the parser error internal rule response (E).]
instead say "[text of parser error internal rule response (E)][paragraph break]". [can't see any such thing]

test me with "touch red robot / transform red car into robot / transform red car into robot / transform red robot / transform green airplane into green airplane / transform green airplane into me / transform me into blue robot / transform me into purple toupee / transform blue robot into gold lame / transform green car into green robot / transform green robot into blue robot / transform green robot into green airplane / transform blue robot into green robot / transform green robot into green car"

Here’s a different version that isn’t so rigid about things having just two shapes and doesn’t need to create a thing per shape-color combo.

lab is a room.

[ third noun by daniel stelzer]
The third noun is an object that varies. The third noun variable translates into I6 as "third".

The understand token third something translates into I6 as "THIRD_NOUN_TOKEN".


Include (-
Global third;
[ THIRD_NOUN_TOKEN  x;
    x  =  ParseToken(ELEMENTARY_TT,  NOUN_TOKEN);
    if  (x  ==  GPR_FAIL  or  GPR_REPARSE)  return  x;
    third  =  x;  return  GPR_PREPOSITION;
];
-).

color is a kind of value.
the colors are colorless, pink, yellow, orange, green.

charm is a kind of thing.
a charm is usually privately-named.
a charm has a color.

shape is a kind of value. The shapes are blob, heart, moon, star, clover.
a charm has a shape.

ur-blob is an undescribed blob charm.
ur-heart is an undescribed heart charm.
ur-moon is an undescribed moon charm.
ur-star is an undescribed star charm.
ur-clover is an undescribed clover charm.

pink-blob is a pink blob charm.
yellow-blob is a yellow blob charm.
green-blob is a green blob charm.
orange-blob is an orange blob charm.

after deciding the scope of the player: repeat with x running through undescribed charms begin; place x in scope; end repeat.

understand the color property as describing a charm.
understand the shape property as describing a charm.
the printed name of a charm is usually "[color of the item described] [shape of the item described]".
when play begins: now every described charm is in the lab.

ur-forming is an action applying to one thing and one visible thing.
understand "form [thing] into [any undescribed charm]" as ur-forming.
the ur-forming action has a shape called original-shape.
setting action variables for ur-forming:
  if the noun provides the property shape, now the original-shape is the shape of the noun.
check ur-forming when the noun is not a charm: instead say "you can't form that.".
carry out ur-forming: now the shape of the noun is the shape of the second noun.
report ur-forming: say "You form the [color of the noun] [original-shape] into a [shape of the noun].".

color-forming is an action applying to one thing and one color.
understand "form [thing] into [color] [third something]" as color-forming.
the color-forming action has a shape called color-original-shape.

setting action variables for color-forming:
  if the noun provides the property shape, now the color-original-shape is the shape of the noun.
check color-forming when the noun is not a charm: instead say "you can't form that.".
check color-forming when the color of the noun is not the color understood: instead say "forming can't change something's color!".

carry out color-forming: now the shape of the noun is the shape of the third noun.
report color-forming: say "You form the [color of the noun] [color-original-shape] into a [shape of the noun].".