MantisBT - Core Inform
View Issue Details
0001787Core InformPhrases and functional programmingpublic2015-11-23 09:272019-03-26 19:25
otistdog 
 
normalseriousalways
newopen 
x86LinuxAny
6L38 
 
(serious/mild) Game compiles but misbehaves
0001787: Condition testing a stored action evaluates incorrectly?
I'm having trouble figuring out how to describe this issue precisely; it may be easiest just to look at the provided demonstration source -- the condition in question is set off by commented asterisks.

I naively be expected that this type of condition would evaluate to true given that a similar construction can be used as part of a rule preamble, and that in such cases it would evaluate to true regardless of the direction in question. However, in this context the compiler seems to expect that a direction will be provided, and in the absence of one specified is perhaps treating the direction as nothing when evaluating the condition.

A workaround in this particular instance can be had (uncomment "[oppposite of way]" after the problem condition to see the expected behavior for the last test-me command), but this feels a bit like a bug.
 
"Scouting"

Place is a room.

Bob is a man in Place.

Other Place is east of Place.

A rock is in Other Place.

A persuasion rule:
persuasion succeeds.

The initiating action is a stored action that varies.

First Before doing something:
now the initiating action is the current action.

First Before asking someone to try doing something:
now the initiating action is the current action.

Every turn:
say "<initiating action = [initiating action] / actor = [actor part of initiating action], action = [action name part of initiating action], noun = [noun part of initiating action]>[line break]";
if the location of Bob is not the location:
let way be the best route from the location of Bob to the location, using doors;
if way is not nothing and the initiating action is the action of going way:
silently try Bob going way;
if the player can see Bob:
say "Bob follows along behind you.";
otherwise if way is not nothing and [****] the initiating action is the action of asking Bob to try going [****] [opposite of way] and the noun part of the initiating action is a direction:
let scouted place be the location of Bob;
silently try Bob going way;
let incidental item be a random thing in scouted place;
if the player can see Bob:
say "Bob returns shortly. 'I saw [an incidental item],' he notes.";
otherwise:
try Bob going way.

test me with "e / w / gonear rock / w / bob, go east"
As a side note, I struggled for a while trying to come up with an equivalent for "something" or "somewhere" that would cover a direction, so that the condition could be phrased, e.g. "asking Bob to try going someway". Even though this would be a feature request, would it be worthwhile to add it?
No tags attached.
Issue History
2015-11-23 09:27otistdogNew Issue
2015-11-23 12:58zarfNote Added: 0004191
2015-11-23 12:59zarfNote Edited: 0004191bug_revision_view_page.php?bugnote_id=0004191#r1271
2015-11-23 12:59zarfNote Added: 0004192
2015-11-23 12:59zarfAssigned To => zarf
2015-11-23 12:59zarfStatusnew => feedback
2015-11-25 01:16otistdogNote Added: 0004193
2015-11-25 01:16otistdogStatusfeedback => assigned
2015-11-25 01:19otistdogNote Edited: 0004193bug_revision_view_page.php?bugnote_id=0004193#r1273
2015-11-25 11:40zarfAssigned Tozarf =>
2015-11-25 11:41zarfStatusassigned => new
2015-11-25 11:50zarfNote Added: 0004196
2015-11-25 12:34otistdogNote Added: 0004197
2019-03-26 19:25otistdogNote Added: 0004836

Notes
(0004191)
zarf   
2015-11-23 12:58   
(edited on: 2015-11-23 12:59)
I'm not sure what problem you're describing. The sample code works correctly, but you want to phrase it differently? Or does it not work correctly?

(0004192)
zarf   
2015-11-23 12:59   
?
(0004193)
otistdog   
2015-11-25 01:16   
(edited on: 2015-11-25 01:19)
Sorry, zarf -- I often seem to have trouble describing the issue concisely.

To be specific: In this case, the condition offset by asterisks, namely the condition "the initiating action is the action of asking Bob to try going" seems like it should evaluate as true if the initiating action (a stored action) is "asking Bob to try going west" or "asking Bob to try going north" or "asking Bob to try going <any direction>".

It does NOT evaluate in this manner; it evaluates to false in those cases.

The sample code does not seem like it is working correctly for the last command ("bob, go e") which should trigger the "Bob returns shortly..." response instead of the "Bob arrives from the east." response provided by the Standard Rules.

The correct response *is* triggered if the commented "[opposite of way]" is uncommented, showing that if the condition's action description contains a noun then it evaluates as expected.

It doesn't seem like the condition *should* have to include a noun given that a similar condition in a rule preamble does not require one, and given that not specifying a noun in a rule preamble causes the rule to apply regardless of the noun. It looks like this type of condition in a rule preamble treats a lack of noun as a wildcard for the noun, while in the example it (apparently) is treating a lack of noun as meaning that the noun must be nothing.

That's what feels like a bug, especially given that there doesn't seem to be any way to force a wildcard treatment via a non-specific noun like "someone" or "something".

Does that make any more sense?

(0004196)
zarf   
2015-11-25 11:50   
Thanks.

I *think* this is a misunderstanding of the way "X is Y" is evaluated when X and Y are stored actions. It's not a pattern-match. In your "if" statement, the first stored action is "asking Bob to try going east" and the second is "asking Bob to try going nothing". These are not equal.

If you change the line to

otherwise if way is not nothing and the initiating action is asking Bob to try going a direction:

...then it's treated as a pattern-match and the code behaves the way you want.
(0004197)
otistdog   
2015-11-25 12:34   
Yes. Darn it, yes. I see the difference now: when I say "action of" and don't provide a noun, it is set to nothing because that's the (legitimately) presumed authorial intent since I constructed a specific action. And I can't use "a direction" within "action of" because that's not a specific direction, as pointed out in WWI 12.20.

My apologies for not taking this to the forum first, and thanks for the help. This can be closed under "reporter failed to understand what he was doing".
(0004836)
otistdog   
2019-03-26 19:25   
Reviewing this, I think that what I was looking for when I submitted the original report was the ability to create a condition with wildcards for objects, similar to that which can be used when creating rule preambles. It's the same idea put forward in the suggestion at: https://inform7.uservoice.com/forums/57320-general/suggestions/32782867-allow-stored-described-actions-and-or-stored-de [^]

6M62 now has a problem message that explains why this syntax is disallowed, but it's not clear why this is undesirable from a design perspective, and the problem message ("... 'asking Bob to try going a direction' is too vague to describe a specific action.") seems somewhat misleading because the sought-after functionality can be created in 6M62 by being a bit more verbose, e.g.: "otherwise if way is not nothing and the actor part of the initiating action is Bob and the action name part of the initiating action is the going action:"