ADRIFT Forum


The place to discuss the ADRIFT Interactive Fiction toolkit

Demo for Po. Prune

This forum is the place to learn about and discuss ADRIFT 5. Feel free to mention any bugs you find here, but please also add these to the Bugs & Enhancements list.

Please also refer to the ADRIFT 5 Wiki for more information.

Demo for Po. Prune

Postby ElliotM » Fri Dec 23, 2011 11:49 pm

This is one simple way to replace the default Player Movement completion text with specialized-but-random messages depending on where you are. Here is an overview of how the effect was achieved:

  • One Text Array variable. The entries should be the specialized responses you want to see. Make note of how many entries it has, mine had four. I named mine BeachMessages.
  • One location group. I named mine "Beach Group". Then I added each beach location where I wanted my Beach Messages to display instead of the standard Player Movement completion text.
  • Next I modified the complete message for Player Movement by adding a Alternate Description with the restriction player must be in a location in location group Beach group. The text was as follows:
    %BeachMessages[RAND(1,4)]%

And that's all there is to it. An enhancement that would be nice would be a no repeat RAND() function, enhancement request here. The sequence 111112 would be considered random but suffers from a lot of repeats, and repeats can break the illusion. A no repeat RAND() function would give us the kind of 'human random' we sort of expect from a randomizer.

Making this scale better might involve properties and another location group, and I may eventually implement this. Right now we'd be hand coding every exception we wanted by adding to the player movement task, and I think we can do better than that.
Attachments
Demo for Po Prune.taf
Now uses Start Description with in the Player Movement Task
(11.98 KiB) Downloaded 84 times
Last edited by ElliotM on Sat Dec 24, 2011 5:20 am, edited 3 times in total.
ElliotM
 
Posts: 1183
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA

Re: Demo for Po. Prune

Postby saabie » Sat Dec 24, 2011 1:47 am

ElliotM wrote:I would like to see Alternate Descriptions have the ability to override the default if their conditions are met.
Thats exactly what "Start description with" does. If an alternate description with this setting passes its restriction then none of the tabs to its left will be displayed under any circumstances.
This is explained in the Wiki.
saabie
 
Posts: 834
Joined: Fri Aug 12, 2011 2:07 am
Location: Adelaide, South Australia

Re: Demo for Po. Prune

Postby ElliotM » Sat Dec 24, 2011 1:54 am

Most interesting, I had always assumed that Start with just made it append to the front/top, after which the default would display as normal.
ElliotM
 
Posts: 1183
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA

Re: Demo for Po. Prune

Postby Po. Prune » Sun Dec 25, 2011 8:19 am

An enhancement that would be nice would be a no repeat RAND() function, enhancement request here. The sequence 111112 would be considered random but suffers from a lot of repeats, and repeats can break the illusion. A no repeat RAND() function would give us the kind of 'human random' we sort of expect from a randomizer.

Hi Elliot
Thanks for your demo. It looks great.
I also like your enhancement request. A no repeat RAND function would sure be great.
Thanks for taking time to help me, and thanks to Daza too. It was cool to talk to you guys on the minichat.
Cheers
D-Day V.5 in progress 79Kb so far (slowly getting there)
Anno 1700 in progress 111Kb
User avatar
Po. Prune
Moderator
 
Posts: 3945
Joined: Mon Jun 24, 2002 8:18 am
Location: Denmark

Re: Demo for Po. Prune

Postby ElliotM » Sun Dec 25, 2011 8:42 pm

Glad you found it useful, and thanks for the vote on the no repeat RAND enhancement.
ElliotM
 
Posts: 1183
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA

Re: Demo for Po. Prune

Postby ralphmerridew » Wed Dec 28, 2011 9:31 pm

Instead of asking Campbell to add a no-repeat RAND replacement, why don't you write your own?

This is a slightly simplified. (Choose a random number from 1 to N; no two consecutive rolls will have the same value; the first roll will not be N.)
1: Create two variables "temporary" and "value 1". (If you need multiple non-repeating RANDs, then create multiple "value" variables; you only need one "temp".)
2: Set "value" to N.
3: Create system task "#Randomize value 1":
-- Task runs anywhere, no conditions.
-- First action sets "temporary" to a RAND(1, N-1)
-- Second sets "value 1" to if (temporary = value, N, temporary).

(If you're willing to do a little more work, you can have all values possible on the first roll.)
Bloodhounds can make you laugh and cuss in the same breath. They are endearing, faithful, and can sling drool ten feet in any direction. -- Virginia Lanier
User avatar
ralphmerridew
 
Posts: 2501
Joined: Fri Dec 13, 2002 11:56 pm
Location: Missouri

Re: Demo for Po. Prune

Postby ElliotM » Thu Dec 29, 2011 12:21 am

Perhaps I wasn't clear enough about what I was looking for. While your code suggestion ensures that no number will directly repeat itself, which is certainly useful and would fit what a NoRepeatRAND() sounds like it should do, I was actually looking for a way to have a sequence 1-N that has no repeats before it starts over. In other words, every member of the range 1-N will be displayed at least once before any of them are repeated. I will take a look another look at how I might use arrays and expressions to implement such a system, but

ralphmerridew wrote:Instead of asking Campbell to add a no-repeat RAND replacement, why don't you write your own?


if I thought I could write it myself with what was available, I wouldn't have made an enhancement request for it. I'm well aware that Campbell is coding Adrift out of his own enthusiasm and spare time, I'm not that insensitive. You've given me some ideas, so I'll give it a shot on my own, but I still think this would be a reasonably useful feature for some time down the road.
Last edited by ElliotM on Thu Dec 29, 2011 2:30 am, edited 1 time in total.
ElliotM
 
Posts: 1183
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA

Re: Demo for Po. Prune

Postby ElliotM » Thu Dec 29, 2011 2:27 am

This is what I've come up with so far:

adrift Code: Select all
Int Value               Will hold a random number 1 through N
Int Range[]             Array of length N which tracks which number has been used with a 1
Int Repeat                      Will tell us if a repeat was detected if it is ever equal to 1.
 
Task NoRepeatSequence
        Set Repeat = 0
        Execute Task Reset
        Set Value = Rand(1,N)
        Execute Task Repeat Check
 
Task Reset
        Restriction: (Range[1]=1 & Range[2]=1 & ... & Range[N]=1)
        Set all Range[1, N] to 0
 
Task Repeat Check
        Set Repeat = If( Repeat=1 OR (Range[1]=1 & Value=1), 1, 0)
        Set Repeat = If( Repeat=1 OR (Range[2]=1 & Value=2), 1, 0)
        ....
        Set Repeat = If( Repeat=1OR (Range[N]=1 & Value=N), 1, 0)
        Execute Task Update Range
        Execute Task LoopNoRepeatSequence
 
Task Update Range
        Restriction: Repeat must not be equal to 1
        Set Range[1]= If (Value =1, 1, 0)
        Set Range[2]= If (Value =2, 1, 0)
        Set Range[3]= If (Value =3, 1, 0)
        Set Range[4]= If (Value =4, 1, 0)
        Set Range[5]= If (Value =5, 1, 0)
        ....
        Set Range[N]= If (Value =N, 1, 0)
 
Task LoopNoRepeatSequence
        Restriction: Repeat must be equal to 1
        Execute Task NoRepeatSequence



Cons:
  • Each instance where we want to track a non-repeating sequence will need a duplicate of nearly everything above except for Value and Repeat unless there is some parameter passing tricks I'm unaware of
  • We would be unable to refer to this fake function inside of text like we can with Rand(1,N), and for text that isn't the result of an action this is a serious limitation. I don't want this to run in the background because that would defeat the purpose of a no repeat sequence as the player would miss seeing some of the results if it kept going when it wasn't needed. Maybe with some planning I could get around this, but a regular function is much easier to deal with.
  • I don't know what the syntax is for checking an array entry inside of a restriction. Appears to not be supported at this time. Maybe another variable set like how we update Repeat could help us know if every entry of the array was equal to 1.
  • Tasks Update Range, Repeat Check, and Reset could probably be rewritten with loops for updating the arrays, which would make the system more flexible
  • Loops are unavailable to single variables, so Set Repeat = If(Test, X, Y) will have to be hardcoded, making it less flexible.
  • This sequence of tasks may loop many times before it completes, which would likely be a significant performance hit.

For the Update Range loop, I was thinking of this:
adrift Code: Select all
 
For 1 to %RangeMax%
Set Range   [LOOP] = If(%Value%=%Loop% && Range[LOOP] !=1, 1, Range[Loop])
NEXT Loop


That is, assuming I can get access to [LOOP] with %Loop%.
ElliotM
 
Posts: 1183
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA

Re: Demo for Po. Prune

Postby ralphmerridew » Thu Dec 29, 2011 6:03 am

ADRIFT doesn't support loops, but you can use recursion:

(You might need to change this slightly if ADRIFT arrays are zero-index instead of 1-indexed.

System Task "#Initialize Array":
- Restrictions:
-- Variable "index" > 0
- Actions:
-- Set Array[index] to index
-- Decrease index by 1
-- Run task "# Initialize Array".
Bloodhounds can make you laugh and cuss in the same breath. They are endearing, faithful, and can sling drool ten feet in any direction. -- Virginia Lanier
User avatar
ralphmerridew
 
Posts: 2501
Joined: Fri Dec 13, 2002 11:56 pm
Location: Missouri

Re: Demo for Po. Prune

Postby ElliotM » Thu Dec 29, 2011 6:06 am

Some form of loop support appears to be implemented, but only for setting array variables. If you create a task and go to the actions and try to set an array variable equal to something, a check box named "I need a loop" will appear. If the variable is not an array, it doesn't show up.

I believe they are 1-indexed, there is no array[0] entry.

At any rate, there are three fields when you check "I need an array", the first two of which are FOR LOOP = [---------] TO [---------], followed by Set Variable [LOOP] = [----------------------------------]. I guess I could create my own index variable if [LOOP] isn't actually anything.
ElliotM
 
Posts: 1183
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA


Return to ADRIFT 5.0

Who is online

Users browsing this forum: No registered users and 3 guests

cron