Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000559Core InformRules and rulebookspublic2011-02-12 20:532014-05-07 07:35
Assigned Tograham 
StatusclosedResolutionno change required 
Platformx86OSWindowsOS Version7
Product Version6G60 
Target VersionFixed in Version6L02 
Summary0000559: Interpretation of definition-based test is different between in-text if block and rule trigger condition
DescriptionThis is something I ran into while trying to rework example 193. I wanted to be able to use the in-built event tracking instead of object-based state-manipulation code when evaluating whether the can had been shaken recently. I also wanted to be able to use a more natural-seeming construction than "if we have shaken..." to do this test -- I found the word "we" to be inconsistent with the rest of Inform 7 phrasing, which made it difficult to remember.

At any rate, I found that many more natural (to me) constructions would not work, such as:

Instead of opening the can of root beer when the can has been shaken...
Instead of opening the can of root beer when the player has shaken the can...
Instead of opening the can of root beer when someone has shaken the can...
Instead of opening the can of root beer when the can has been shaken by the player...
Instead of opening the can of root beer when the can has been shaken by someone...

and then I set about trying to produce the ability to use that kind of phrasing with a decision rule:

To decide whether (the shakee - a thing) has been shaken:
if we have shaken the shakee, decide yes;
decide no.

This compiles but produces strange behavior, the most serious of which is that at a given point in time, the same test produces different results depending on the code's context (in a text string if condition vs. in a rule trigger test). See comments in attached example for further details.

Any or all of this strangeness may be tied to including "for less than 4 turns" as part of the test. Placing this condition directly in the decision rule causes a compiler crash (see 0000484).
Minimal Source Text To Reproduce
There is a room.
The can of root beer is a closed openable container carried by the player.

Understand "shake [something preferably held]" as shaking.
Shaking is an action with past participle shaken, applying to one carried thing.

To decide whether (the shakee - a thing) has been shaken:
	decide on whether or not we have shaken the shakee.

Instead of opening the can of root beer when the can has been shaken for less than four turns:
	say "(Unexpected result)."

Test me with "shake can / z / z / z / open can".
TagsNo tags attached.
Effect(serious/mild) Game compiles but misbehaves
Attached Files

- Relationships
has duplicate 0000710closed when conditions behave differently from if conditions when referring to past tense 

-  Notes
EmacsUser (manager)
2011-02-24 15:37

There are two bugs, one in the source text and another that could be argued as an Inform bug.

First, after ``[5] listen to can,'' the can has been shaken for zero turns, which is less than four; Inform is technically correct in printing ``fizzy.'' The intended text substitution is probably ``if the can has been shaken and the can has been shaken for less than 4 turns]fizzy[otherwise]calm[end if].''

Second, Inform is reading

- - - -
Instead of opening the can of root beer when the can has been shaken for less than 4 turns:
- - - -

as ``Instead of opening the can of root beer for less than 4 turns'' with the extra condition that ``the can has been shaken.'' Put another way, the rule fires whenever the can has been shaken and the player is opening the can fewer than four times in a row. And being the more specific of the two, this rule trumps the one marked ``never seems to execute.''

A workaround for the latter problem is to extract the condition in another phrase:

- - - -
To decide whether the can is fizzy:
    decide on whether or not the can has been shaken for less than 4 turns.

Instead of opening the can of root beer when the can is fizzy:
- - - -

I've reduced the source text and confirmed.
otistdog (reporter)
2011-02-24 16:04
edited on: 2011-02-24 16:04

I'm not sure I fully understand what your note is about, EmacsUser, but I am concerned that my initial submission may have been based on a misunderstanding of what the phrase "if the can has been shaken for less than 4 turns" means in Inform 7.

The idea that I was trying to implement was similar to the original example's: after shaking, the can would be fizzy and prone to exploding for a certain interval of time, after which it would go flat. I believed from reading WWI 9.15 that "for less than 4 turns" would be establishing a length of time between the initial shaking event and the current turn, but your comment seems to imply that this would actually be establishing the number of consecutive turns in which the can was shaken. Is that correct?

EmacsUser (manager)
2011-02-24 17:07

Your understanding of WI 9.15 is correct. But the qualifier ``for less than 4 turns'' takes on a slightly different meaning as a guard on a rule---that's where it refers to consecutive turns of an action. Thus,

- - - -
There is a room.
Instead of jumping for less than 4 turns: say "You lack the nerve."
Test me with "jump / g / g / z / jump / g / g / g".
- - - -

Unfortunately, Inform is breaking ``when the can has been shaken for less than 4 turns'' in your test case into two conditions: ``when the can has been shaken'' and ``for less than 4 turns.'' It therefore reads ``for less than 4 turns'' in the same sense as in the jumping example, contrary to how humans would parse the sentence, and also to what one might expect based on WI 9.15.
otistdog (reporter)
2011-02-24 18:10

Thank you for the clarification. I think I understand better what's going on now.

I would also like to understand better your comments concerning the text substitution part of my initial submission, which I believe you classified as a source text bug: Why would making the test contain two conditions "the can has been shaken" and "the can has been shaken for less than 4 turns" be necessary?

I don't understand this unless:

A) "the can has been shaken" is treated by the compiler as identical to "the can has been shaken at least once", and

B) the number of turns the can has been shaken is treated as zero (which, as you note, is less than 4) before the first shake.

Are both these assumptions correct?
EmacsUser (manager)
2011-02-27 19:03

Yes, my understanding is that both A and B are correct.
intheshax (reporter)
2011-07-27 16:21

The solution then would seem to be to allow qualifiers like "for x turns" between the action specification and the word "when" in a rule, and to have those qualifiers apply to the action. When the qualifiers come at the end, after "when" and an expression, the qualifier would apply to the expression.

So this would now be valid syntax: "Instead of shaking the can for 4 turns when the can is agitated...". It would fire on the 4th consecutive shake once the can was agitated.

That would free up "Instead of shaking the can when the can has been agitated for more than 4 turns..." to do as it would intuitively seem it should do. It would fire on any shake of a can that has been in an agitated state for that many consecutive turns.
graham (administrator)
2014-01-18 09:46

Maybe it should be "won't fix", but I think this is a consistent if tricksy behaviour, and not a bug as such.

- Issue History
Date Modified Username Field Change
2011-02-12 20:53 otistdog New Issue
2011-02-22 16:31 jmcgrew Status new => acknowledged
2011-02-24 14:58 EmacsUser Description Updated View Revisions
2011-02-24 15:37 EmacsUser Note Added: 0001046
2011-02-24 15:37 EmacsUser Steps to Reproduce Updated View Revisions
2011-02-24 15:37 EmacsUser Status acknowledged => confirmed
2011-02-24 16:04 otistdog Note Added: 0001047
2011-02-24 16:04 otistdog Note Edited: 0001047 View Revisions
2011-02-24 17:07 EmacsUser Note Added: 0001050
2011-02-24 18:10 otistdog Note Added: 0001051
2011-02-27 19:03 EmacsUser Note Added: 0001055
2011-07-26 19:31 EmacsUser Category Phrases and functional programming => Rules and rulebooks
2011-07-26 19:36 EmacsUser Relationship added has duplicate 0000710
2011-07-27 16:21 intheshax Note Added: 0001235
2014-01-18 09:46 graham Note Added: 0002307
2014-01-18 09:46 graham Status confirmed => resolved
2014-01-18 09:46 graham Resolution open => no change required
2014-01-18 09:46 graham Assigned To => graham
2014-05-07 07:34 jmcgrew Fixed in Version => 6L02
2014-05-07 07:35 jmcgrew Status resolved => closed

Copyright © 2000 - 2010 MantisBT Group
Powered by Mantis Bugtracker