|Anonymous | Login | Signup for a new account||2019-02-18 19:20 PST|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0000559||Core Inform||Rules and rulebooks||public||2011-02-12 20:53||2014-05-07 07:35|
|Status||closed||Resolution||no change required|
|Target Version||Fixed in Version||6L02|
|Summary||0000559: Interpretation of definition-based test is different between in-text if block and rule trigger condition|
|Description||This 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;
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".
|Tags||No tags attached.|
|Effect||(serious/mild) Game compiles but misbehaves|
There are two bugs, one in the source text and another that could be argued as an Inform bug.
First, after `` 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.
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?
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.
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?
|Yes, my understanding is that both A and B are correct.|
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.
|Maybe it should be "won't fix", but I think this is a consistent if tricksy behaviour, and not a bug as such.|
|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|