intfiction.org

The Interactive Fiction Community Forum
It is currently Sat May 25, 2013 12:11 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 13 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sat Apr 21, 2012 4:49 am 
Offline

Joined: Sat Jul 09, 2011 2:09 am
Posts: 19
Related to my previous topic (working distance and speed into going actions), I've decided to overhaul Eric Eve's Variable Time Control to allow for even more ridiculous levels of micromanagement. That's just the kind of coder I am. Basically, what I want (also see flowchart below) would be to run through the first time, add the delay, get out, wait for my while loop to reach the specified period, and restart the action with a toggle indicating that the normal progression should occur. The easiest way I see to do this would be to store the action when the first delay is added and call it again after the wait ends. Unfortunately, I want to allow this for NPC characters as well, so the action would have to be stored as a property of a person, and it doesn't seem like actions are an accepted kind of value in that situation. Is there any way to do this, or will I have to come up with some other method?

Code:
      ┌─────→ Input
      │         ↓
    Wait      Check ←─*── Wait
      ↑         ↓          ↑
      │      Lead-in ─→ Add time
      │        ²↓    ¹
  Add time  Carry out
      ↑         ↓
      └───── Recovery

* Leading back to the check ensures
  continued legality if world changes.


Top
 Profile Send private message  
 
PostPosted: Sat Apr 21, 2012 6:20 am 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 2128
Location: Burlington, VT
This line compiles for me, though I didn't do anything with it; is there another problem you're encountering with using it?

Code:
Every person has a stored action called the pending action.


Top
 Profile Send private message  
 
PostPosted: Sat Apr 21, 2012 11:49 am 
Offline

Joined: Sat Jul 09, 2011 2:09 am
Posts: 19
Yeah, that does it. I somehow missed that section of the docs and wasn't adding the "stored" part of the name. Sorry for bothering you needlessly!


Top
 Profile Send private message  
 
PostPosted: Sat Apr 21, 2012 2:11 pm 
Offline

Joined: Sat Jul 09, 2011 2:09 am
Posts: 19
All right, it's decided to stop working again, this time by (apparently) entering an infinite loop. What I have runs the first turn perfectly, takes the object (testing with that verb), prints the name of the room again, then freezes. It also does not increase the time. What makes this all the more annoying is that it was working not that long ago, but I made some small tweak and was worse off than I had been for a while. I no longer remember what the change was, and the various taskkills have not been to good for my undo history. Can any of you spot what's causing this?
Code:
The seconds are a number that varies. The seconds are 0.

Every person has a stored action called the pending action.
Every person has a number called the wait timer.
Every person has a truth state called the preparation toggle.

This is the time progression rule:
   while the wait timer of the player is not 0 or the preparation toggle of the player is not false:
      repeat with the character considered running through people:
         unless the wait timer of the character considered is 0:
            decrement the wait timer of the character considered;
         if the wait timer of the character considered is 0:
            if the preparation toggle of the character considered is true:
               now the preparation toggle of the character considered is false;
               try the pending action of the character considered;
               now the pending action of the character considered is the action of waiting;
      increment the seconds;
      if the seconds are 60:
         now the seconds are 0;
         increment the time of day;
         abide by the timed events rule.
The time progression rule is listed instead of the advance time rule in the turn sequence rules.
The timed events rule is not listed in the turn sequence rules.

The prepare rules are a rulebook in the specific action-processing rulebook.
A specific action-processing rule (this is the prepare stage rule):
   if the preparation toggle of the actor is false:
      now the preparation toggle of the actor is true;
      now the pending action of the actor is the current action;
      abide by the prepare rules.
The prepare stage rule is listed before the carry out stage rule in the specific action-processing rulebook.


Top
 Profile Send private message  
 
PostPosted: Sat Apr 21, 2012 3:04 pm 
Offline
User avatar

Joined: Thu Nov 04, 2010 6:30 am
Posts: 986
Location: Gothenburg, Sweden
After the time progression rule sets the preparation toggle to false, it tries the pending action. But before the pending action is carried out the prepare stage rule runs, and it resets the preparation toggle to true, which means the conditions of the while loop in the time progressions rule is met anew, ad infinitum.

_________________
Man ska inte tro allt man tänker.


Top
 Profile Send private message  
 
PostPosted: Sat Apr 21, 2012 3:58 pm 
Offline

Joined: Sat Jul 09, 2011 2:09 am
Posts: 19
Ah. I knew there was a reason I put the reset in the prepare stage when I first wrote it. Thanks for pointing that out!

EDIT: Just to head off the possible advice, I know that it works just as well after the call to the action. That's where it is now.


Top
 Profile Send private message  
 
PostPosted: Sat Apr 21, 2012 9:28 pm 
Offline

Joined: Sat Jul 09, 2011 2:09 am
Posts: 19
Sorry for the double posting, but this should be the last question I have in this thread. As part of the time advancement stage, I want to provide a weak hook for including AI. Using a rulebook, I have created what I believe will do nothing by default, while still allowing easy access to that feature (see below again). It should work, except for filling in the actor. Is there any way to access the (in this case) person that an object-based rulebook is working on? Essentially, I want to find some analogue of "actor" (though, as I understand it, that's a rulebook variable, not a subject) so I can write something similar to "rule succeeds with result the action of the actor waiting."
Code:
This is the time progression rule:
   while the wait timer of the player is not 0 or the pending action of the player is not the action of waiting:
      [irrelevant]
      repeat with the character considered running through people who are not the player:
         [irrelevant]
         if the wait timer of the character considered is 0 and the pending action of the character considered is waiting:
            let the chosen action be the stored action produced by the action selection rules for the character considered;
            if the chosen action is not waiting:
               try the chosen action.

The action selection rules are a person based rulebook producing a stored action.
A action selection rule (this is the default action selection rule):
   rule succeeds with result the action of waiting.


Top
 Profile Send private message  
 
PostPosted: Sun Apr 22, 2012 10:47 am 
Offline
User avatar

Joined: Thu Nov 04, 2010 6:30 am
Posts: 986
Location: Gothenburg, Sweden
I think it's as simple as this.
Code:
Action selection someone (called John Doe) (this is the default action selection rule):
   rule succeeds with result the action of John Doe waiting.

_________________
Man ska inte tro allt man tänker.


Top
 Profile Send private message  
 
PostPosted: Sun Apr 22, 2012 11:42 am 
Offline

Joined: Sat Jul 09, 2011 2:09 am
Posts: 19
That looks like it works. Now, though, I'm getting an error in a related location (different rulebook, but same structure). The line is in a "setting action variables" rule for going—and appears in the right location in the index—which should give it access to the actor. Unfortunately, that's what Inform's complaining about. If I include "for the actor", it tells me it can't recognise the last two words. If I take them off, it says that the going speed selection rules are people-based and I need someone to apply it to ("for the player" works perfectly, but is not general enough).
Code:
Rule for setting action variables for going (this is the timed set going variables rule):
   now the speed gone at is the number produced by the going speed selection rules for the actor;
   [continued]


Top
 Profile Send private message  
 
PostPosted: Sun Apr 22, 2012 1:44 pm 
Offline

Joined: Sun Dec 05, 2010 11:07 am
Posts: 321
Location: ኢትዮጵያ
WovenTales wrote:
That looks like it works. Now, though, I'm getting an error in a related location (different rulebook, but same structure). The line is in a "setting action variables" rule for going—and appears in the right location in the index—which should give it access to the actor. Unfortunately, that's what Inform's complaining about. If I include "for the actor", it tells me it can't recognise the last two words. If I take them off, it says that the going speed selection rules are people-based and I need someone to apply it to ("for the player" works perfectly, but is not general enough).
Code:
Rule for setting action variables for going (this is the timed set going variables rule):
   now the speed gone at is the number produced by the going speed selection rules for the actor;
   [continued]

I think you need to include "the actor" in the name of the rule as well, to tell Inform that it needs to apply to any actor attempting to go, not just the play.

At least, this minimal source compiles and runs for me:
Code:
There is room.

The going action has a number called the speed gone at.

Rule for setting action variables for an actor going (this is the timed set going variables rule):
   now the speed gone at is the number produced by the going speed selection rules for the actor;
   showme  the speed gone at;
   [continued]
   
The going speed selection rules are a people based rulebook producing numbers.

A going speed selection rule:
   rule succeeds with result 1.


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 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