intfiction.org

The Interactive Fiction Community Forum
It is currently Sat May 26, 2018 3:45 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sun May 13, 2018 6:24 am 
Offline

Joined: Mon Dec 07, 2009 9:14 am
Posts: 184
Location: Chicago, IL
What I'm trying to do is allow an end of story scenario to play out but once the obituary part occurs, to stop it. This is for some unit testing tools I'm doing where some actions do lead to an end of game but I want the end of game output to be accepted but then simply nullify that the end of game occurred.

More specifically, I want to stop the question "Would you like to RESTART, RESTORE a saved game, QUIT or UNDO the last command?" from being asked as that kills any unit testing tools in their tracks.

Just to see if I could get avoiding the question to work at a simple level, I tried this:

Code:
Rule for printing the player's obituary:
    say "Avoid Death" instead.

That doesn't work. The question is still asked.

I tried:

Code:
Rule for printing the player's obituary:
    end the printing the player's obituary activity.

That doesn't work. The question is still asked but you get:

*** Run-time problem P13: Tried to abandon an activity which wasn't going on

Then I tried:

Code:
After printing the player's obituary:
    end the printing the player's obituary activity.

That doesn't work, you get:

Glulxe fatal error: Stack overflow in function call.

I also tried to abandon -- rather than end -- the activity and the same errors mainly still occur. For example, I tried this:

Code:
After printing the player's obituary:
    abandon the printing the player's obituary activity.

The question still gets asked but you get this set of errors:

[** Programming error: tried to write to -->-1 in the array "activity_parameters_stack", which has entries 0 up to 19 **]
[** Programming error: tried to write to -->-1 in the array "activities_stack", which has entries 0 up to 19 **]


I also tried to just fail the rule, like this:

Code:
Before printing the player's obituary:
    rule fails.

No errors come up but it doesn't do anything. The question is still asked.

Basically if you try to do anything with "Before" or "Rule for" with this activity, you get an error about how the activity wasn't going on or nothing at all happens. So it seems like you have to handle things in the "After" part of the handling, but that leads to various types of errors.

So maybe the better question here is how you can entirely subvert how an end of game ("obituary") part of Inform works.

Any ideas?


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sun May 13, 2018 9:56 am 
Offline

Joined: Sat Jan 23, 2010 4:56 pm
Posts: 5649
You can skip the final question step; the interpreter will then proceed to quit.

Code:
The ask the final question rule is not listed in the shutdown rulebook.


If you want to cancel death entirely, and instead return to the parser loop, you can instead add:

Code:
When play ends: 
   resume the story.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sun May 13, 2018 10:09 am 
Offline

Joined: Mon Dec 07, 2009 9:14 am
Posts: 184
Location: Chicago, IL
Ah, interesting. Okay, I needed to be looking at the shutdown rulebook, which probably should have been obvious to me.

I do like the "cancel death entirely" part as I do need the interpreter to continue since there may be more tests to run. And then, given that, I think I may have to change my extension a bit. Specifically, I'm referring to the i7Spec.i7x extension. And by change it, I mean I wonder if I should make the spec processing an activity instead.

And I say that because I would only want the "cancel death entirely" part to be operative when the spec processing is running. During normal play -- including with the "test" command built in to Inform -- I would want the end of game style functionality to work as it should. So I would need the "When play ends: resume the story" part to be conditional upon a context, which it seems would be more suited to an activity.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sun May 13, 2018 10:23 am 
Offline

Joined: Sat Jan 23, 2010 4:56 pm
Posts: 5649
I note that I do all my Inform unit testing with a framework around the interpreter, not in-game extensions. I don't want to worry about the in-game test code changing the game behavior in an unexpected way.

I realize that there are many valid testing approaches, of course. :)


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sun May 13, 2018 10:43 am 
Offline

Joined: Mon Dec 07, 2009 9:14 am
Posts: 184
Location: Chicago, IL
Totally understood on that! The main reason I'm doing this is because I use Inform 7 for teaching about testing itself: spotting test and data conditions, for example, as well as how and when to combine tests (and when not to). Just to give you an idea, here's what I produce in the source text with that extension:

Code:
Scenario:
   context "player can't take the message if the box is closed";
   verify that "take message" produces "The glass box isn't open."

Scenario:
   context "player can't open the glass box and accidentally kill themselves";
   verify that "open glass box" produces "You're deterred by the swirling bottle-green mist within."
   
Scenario:
   context "player can't examine the message if they're not holding it";
   verify that "examine message" produces "You need to be holding it before you can read it."
   
Scenario:
   context "Kitty can take the message without opening the glass box";
   verify that "Kitty, get the message" produces "As her hands pass through the glass box, Kitty Pryde picks up the message.";
   verify that "examine box" produces "In the glass box are some poison gas."
   
Scenario:
   context "Kitty won't take the poison gas when asked";
   verify that "Kitty, take the gas" produces "Kitty looks at you as if you were an idiot. 'How exactly do you expect me to do that?'"
   
Scenario:
   context "the player is killed in the presence of Kitty, who observes";
   do "kitty, open the box";
   verify that "wait" produces "Time passes.[paragraph break]The poison gas has reached your lungs.[line break]Kitty seems to take a disturbing interest in your writhing spasms.";

These are really more meant to be acceptance tests than unit tests because I can string together a series of commands. That last scenario is a case in point of where the action of Kitty opening the box and then waiting one turn causes death. That text being verified is the final text the player sees but that's also what produces the question and the end of game scenario. It's that part that I'm trying to deal with.

All that being said, none of that negates your statement and may in fact be a point in favor of it. Perhaps I should be looking to do this more outside of the game itself. The reason I glommed onto this approach is because I did like Inform's built in test mechanism and wanted to augment it a bit. Also, I can have my classes just look at a source file and have them enter scenarios in their own example source and then we see what does (and doesn't) make sense.


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Baidu [Spider] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group