Something-ing it at response problem

I’ve got this action:

Understand "throw [something preferably held] at/against [something]", "throw [something preferably held] [something]" as chucking it at.

I noticed that in circumstances that cause Inform to print a clarifying phrase in brackets after what the player typed and before the response, the phrase for this action is graceless.

For instance, if I type “throw paper plane john”, it says

(the paper plane John)

when I’d hoped it’d say

(the paper plane at John)

How can I wrangle it so this happens? Thanks.

Looks like 17.28 should be useful. How about this (untested)?

Rule for clarifying the parser's choice of something while throwing: say "([the noun] at [the second noun])"

Hm. It doesn’t like that. It acts like ‘chucking it at’ is not an action.

“You wrote ‘Rule for clarifying the parser’s choice of something when chucking it at’ : but I don’t understand the ‘when/while’ clause, which should name activities or conditions.”

I was fiddling and tried ‘when chucking something at’, which compiled. I thought ‘Aha!’. But actually that made no change to what the parser was doing at the trouble moments.

Example case, because it took me a little work to construct this:


The Kitchen is a room. 

Chucking it at is an action applying to two things.
Report chucking:
	say "Chucking [noun] at [second noun]."

The paper cutter is in the Kitchen.
The player carries the paper plane.
John is a person in the Kitchen.

Understand the command "throw" as something new.
Understand "throw [something preferably held] at/against [something]" as chucking it at.
Understand "throw [something preferably held] [something]" as chucking it at.

Test me with "throw paper John".

It looks like the “clarifying” activity is simply ignored when the command being printed has two nouns. This is annoying.

You could hack up the I6 PrintInferredCommand() routine to cover your case, or to invoke a new activity that covers it.

I’m also curious what commands this is intended to cover, since “throw plane John” isn’t something IF players would naturally type. Would that be “throw John the plane”? Or is this a “throw plane north” situation?

Thanks for confirming this, zarf; this was confusing me.

It also seems as though sometimes I7 is winkling the syntax for this out of “understand” phrases. If I delete the line without prepositions and reorder the ones with “at” and “against,” I can get it to respond to “throw” with “(the paper plane at the paper plane)” or “(the paper plane against the paper plane)” depending on the order. But if the line without prepositions is in there, it always seems to respond to “throw” with “the paper plane the paper plane.”

It always works that way. However, the precedence order is the internal order of the grammar table, which is not the same as your Understand declarations.

Thanks for looking into this everyone.

Re: what it’s intended to cover. My game’s being playtested at the moment, and 2 of the first 3 testers tried to throw a pie by typing ‘throw pie (person)’, and left out the ‘at’. I noticed this in their transcripts, and that the game wasn’t understanding them. So that’s when I added ‘throw (object) (person)’ as another grammar construct the game should understand, and when I tested that is when I noted that it was giving the plain 'ol (-person-object-) response.

Regarding an i6 hack… does a kind soul who knows i6 feel like writing one for me?

I don’t know i6 and I’m not schooled in other languages with similar syntax to i6 or anything. Even if I begin to learn something about it, now isn’t the time, as I’m preparing a game for ifcomp.

What would this hack be? In a sense, I’m not entirely sure. When Zarf said that the ‘rule for clarifying…’ doesn’t get a look in if the action uses two nouns, what do we instead call the moment when the game prints ‘(something at something)’?

Anyway, I guess what I’d like is - if the game prints a bracketed clarification, and it’s doing it for an action making use of two nouns, I’d like it to print the preposition(s) in between that the player typed. I assume it can get these from what the player typed? By definition, if we made it to this point where we’re printing clarification, the command must have been valid, therefore, whatever was typed between noun one and noun two must be valid, and the game could just blindly reprint it without even knowing what it ‘was’.

If that’s too difficult, I’d be okay for bracketed clarifications to just be silenced in the case of actions involving two nouns. I only have a few such commands in my game, and there probably wouldn’t be much trouble losing clarifications in those cases.

Either way, many thanks if someone takes this on.

It seems like the right response to code something to support what your playtesters are trying, but I wonder if it would be safer to use an:

understand 'throw [something] [something]' as a mistake ("You need to use a preposition.")

It seems a little unfair, but the grammar is somewhat vague, and I generally like to reject a command if I’m not sure it was understood. Here’s an example of why I don’t like this grammar:

[code]Soylent Green is an edible thing. Soylent Yellow is an edible thing. Green Guy is a man. Red Guy is a man.

test me with “throw soylent green guy”[/code]

Or even worse (this is a bit contrived, but something like this could happen:

[code]A small round stone is a thing. A stone statue is a thing.

Test me with “throw stone statue”[/code]

Alternatively, you could try this (not tested) hack:

[code]Shorthand-throwing it at is an action applying to two things. Understand “throw [something] [something]” as shorthand-throwing it at.

Check shorthand-throwing it at:
say “(throwing [the noun] at [the second noun])[command clarification break]”;
instead try throwing the noun at the second noun.[/code]

Hehe, I had already tried diverting via another command. It doesn’t work since the second command still prints its own stuff in brackets.

This particular game already supports (and encourages) so much prepositionless stuff, I think people would be annoyed if they were suddenly told they needed to add one to make a command work.

At least it wouldn’t mess up the message when the player does use a preposition.

But my message is okay if the player does use a preposition. Maybe you’re referring to the code demo Zarf set up? I didn’t run it myself.

I must have misunderstood.

I fear this is hideously “ad hack”. It checks not for the chucking action but for the use of the command “throw”. It might work though, at least until someone who really knows I6 codes a good solution.

Include (- 
[ PrintInferredCommand from singleton_noun;
	singleton_noun = FALSE;
	if ((from ~= 0) && (from == pcount-1) &&
		(pattern-->from > 1) && (pattern-->from < REPARSE_CODE))
			singleton_noun = TRUE;
	if (singleton_noun) {
		BeginActivity(CLARIFYING_PARSERS_CHOICE_ACT, pattern-->from);
		if (ForActivity(CLARIFYING_PARSERS_CHOICE_ACT, pattern-->from) == 0) {
			print "("; PrintCommand(from); print ")^";
		}
		EndActivity(CLARIFYING_PARSERS_CHOICE_ACT, pattern-->from);
	} 
	else {
		print "("; PrintCommand(from); print ")^";
	}
];

[ PrintCommand from i k spacing_flag objs; !#Added objs
    if (from == 0) {
        i = verb_word;
        if (LanguageVerb(i) == 0)
            if (PrintVerb(i) == 0) print (address) i; 
        from++; spacing_flag = true;
    }
    for (k=from : k<pcount : k++) {
        i = pattern-->k;
        if (i == PATTERN_NULL) continue;
        if (spacing_flag) print (char) ' ';
        if (i == 0) { print (string) THOSET__TX; jump TokenPrinted; }
        if (i == 1) { print (string) THAT__TX;   jump TokenPrinted; }
        if (i >= REPARSE_CODE) { !#Added brace 
            print (address) VM_NumberToDictionaryAddress(i-REPARSE_CODE);
            objs = 0; } !#Added line
        else
            if (i ofclass K3_direction)
                print (LanguageDirection) i; ! the direction name as adverb
            else 
                { if (verb_word == 'throw' && (objs == 1))  print "at "; !#Added line
                print (the) i; 
                objs++; } !#Added line
      .TokenPrinted;
        spacing_flag = true;
    }
];
-) instead of "Print Command" in "Parser.i6t".

Thanks very much for that Felix, I will try it out.

That code works, if anyone else wants to benefit from Felix’s mad skilz.