Barotrauma

Barotrauma

Not enough ratings
Random Number Generator
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
136.067 KB
12 Apr, 2020 @ 8:50am
12 Apr, 2020 @ 8:50am
2 Change Notes ( view )

Subscribe to download
Random Number Generator

Description
This primitive psuedo-random number generator uses the equation $X_{n+1} = (aX_{n}+b) mod m$ to generate a random number. By default, it is between 0 and 100. This can be changed by tweaking m (the maximum number generated is m-1). The initial values of a and b can also be changed to change the initial number, and how they cycle - the order will always be the same.

This has some pretty major limitations:
- The adder and multiplier components are both clamped between ±999999, meaning any number bigger than 999999 becomes 999999 (and similar for -999999) so the system has to not create numbers larger than that. This reduces the quality of the random sequence. If you want to tweak the range of the generated number, I recommend highly that you adjust all of a, b, and m to get the best results.
- The initial value will always be the same. It will also always follow the same order. To get different numbers each time, selecting numbers based on a variable time is easier than selecting the 1st, then 2nd etc. number.
- Given initial conditions may not be capable of generating every number in the range. If this happens, tweak a or b slightly and try again.

Some tricks on selecting values for a and b:
The clamps are at roughly 1000000 = 10^6. So we can work with numbers up to that big. The first number to consider is m. Try and select a such that a * m is roughly 10^5. Then select b anywhere up to the order 10^5. This maximises the quality generated.

Hopefully this will be obsolete soon - a random number component should be coming soon (TM).
3 Comments
Black Lenin 11 Mar, 2023 @ 6:16am 
@Mr.WereWolph )))
Mr.WereWolph 25 Feb, 2023 @ 10:22am 
"A random number component should be coming soon"

Made in 2020 and as of 2023 there is yet to be a random component.

I cry.
Macie 13 Apr, 2020 @ 7:04am 
really good