Jump to content

RandomNum()... how random?


Recommended Posts

How is RandomNum() processed? If I have multiple instances of it, how random will it be? Probably best to give an example.


IF ~RandomNum(4,1)~ THEN s1

SAY ~What is your favorite color?~

+ ~RandomNum(6,1)~ + ~Red~ + s2

+ ~RandomNum(6,2)~ + ~Crimson~ + s3

+ ~RandomNum(6,3)~ + ~Vermillion~ + s4

+ ~RandomNum(6,4)~ + ~Maroon~ + s5

+ ~RandomNum(6,5)~ + ~Pink~ + s6

+ ~RandomNum(6,6)~ + ~Scarlet~ + s7

+ ~RandomNum(4,1)~ + ~Blue~ + s8

+ ~RandomNum(4,2)~ + ~Indigo~ + s9

+ ~RandomNum(4,3)~ + ~Azure~ + s10

+ ~RandomNum(4,4)~ + ~Cerulean~ + s11

+ ~RandomNum(4,1)~ + ~Green~ + s12

+ ~RandomNum(4,2)~ + ~Viridian~ + s13

+ ~RandomNum(4,3)~ + ~Pine~ + s14

+ ~RandomNum(4,4)~ + ~Shamrock~ + s15



And then repeat for the triggrs


IF ~RandomNum(4,2)~ THEN s1b

IF ~RandomNum(4,3)~ THEN s1c

IF ~RandomNum(4,4)~ THEN s1d


Will the same random number be used for all the transitions as for the state? Will "pink" and "scarlet" ever show up? Or will the player just see


What is your favorite color?





rather than


What is your favorite color?







What is your favorite color?





Yes, there is a reason for this. I'm experimenting with a random conversation generator and I'd like to know how random the transitions are relative to the lead-in state.

Link to comment

RandomNum() is calculated from the master random, which is only updated once per frame. So all of those triggers are going to be running off the same value, and only three will ever be true (however, the calculation for range=6 is not necessarily going to return the same as for range=4, so something like Red-Green-Blue is unlikely).


I believe the frame is not advanced between the time the state is chosen and the response list generated, so you'd actually only ever get the 4,1 responses from the last eight (you need to use a different range if you want it to be random because the range=4 calculation will always be the same on the same frame; the range=6 list should appear random enough). The frame is updated when you select the response, so the triggers in the next state's responses will be working off a new master value.


Shuffling it so that the three "groups" have different ranges (like 6-5-3) is the best way to get random-seeming response lists.

Link to comment


This topic is now archived and is closed to further replies.

  • Create New...