How to make Pseudorandom Numbers, the Quick and Dirty way

Alright, here’s a way to fake random rolls. Fake, you heard me.

I made this after I died in Breach in the middle of a fun fail state. I was a bit surprised when the story completely changed after the reload, I wanted to get back to that first version of the story. I tried dying a few times more but I never got that first scene again.

If any writer wants players to be able to retrace their steps, but keep the randomness between games and players. Here you go.

How To

The SETUP (startup.txt)

  1. Create a .txt file and write in the code, in this example I name the file “pseudorandom.txt”
  2. In startup.txt, [*create] the variable PRGseed and set it as a [*random] number at the beginning of the game, for example I set it as 3553.
  3. call up the generator like so:
*gosub_scene pseudorandom generator "variable name IN QUOTES" minimum_number maximum_number

for example *gosub_scene pseudorandom generator “strength” 0 20 sets the variable strength as a number between 0 and 20

The CODE (pseudorandom.txt)

>>>> create a txt file and paste this code in there!! then, delete this line<<<<
*label generator
*params variable minimum maximum
*temp a 2175143 
*comment ^ multiplier
*temp c 10653 
*comment ^ the increment
*temp m 1000000
*comment ^ the modulus
*set PRGseed (((PRGseed * a) + c) modulo m)
*set {variable} round((((PRGseed/m))*(maximum-minimum))+minimum)
*return

The temp variables a, c and m can all be changed but really all you need to change between games is the PRGseed variable. Remember to randomly roll that at the start of the game! Otherwise every player will have the same results as each other.

It might be a fun idea to let players input their own seed, that’s just a suggestion though!

1 Like

Couldn’t you also create all the random numbers you’ll need at the start of the game? Of course, that’d require you to have variables for all of them, which may or may not be ideal, depending on what you want.

True. This is mainly for games with dice rolls like Breach, or scenes with randomness in them. If a character wins a card game but then you reload, they’ll still win the card game if you do the same steps. I don’t know how many *rands there are in breach but I imagine it’d be a lot of one time variables if it was done your way