Seed based RNG

HomelessWilliam

Villager
Member
Joined
Jun 25, 2015
Messages
14
Reaction score
1
First Language
Swedish
Primarily Uses
I would like a seed system that makes it so the RNG is consistant if you replay the game with the same seed. I guess the RNG needs to be specific to each event. Is this even possible?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,359
Reaction score
7,672
First Language
German
Primarily Uses
RMMV
theoretically yes - practically it requires someone who knows how to program a random number generator in javascript.

And I suggest you rename the topic as the current topic title "seed system" is extremely misleading.
What you want is not a seed system but a random number generator that is based on a seed number.
This might not sound as much of a difference to you, but for a programmer that is extremely different.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,248
Reaction score
1,250
First Language
Spanish
Primarily Uses
RMVXA
random and seed-based are mutually exclusive.
you can't have predictability in a random system.... that's the foundation of *randomness*
 

HomelessWilliam

Villager
Member
Joined
Jun 25, 2015
Messages
14
Reaction score
1
First Language
Swedish
Primarily Uses
random and seed-based are mutually exclusive.
you can't have predictability in a random system.... that's the foundation of *randomness*
I thought all the RNG was based on preprogrammed code within the computer, a computer doesn’t have the ability to be truly random anyway, right? In that case you don’t believe that RNG exists at all.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,248
Reaction score
1,250
First Language
Spanish
Primarily Uses
RMVXA
no, there is no true randomness, but there is a degree of statistical probability that leads towards equal distribution of occurrences across your scope of values *for "randomness"*
for *seed-based* generation, there is a degree of predictability: you WILL find a given value after a minimum number of tries, which defeats *probability* (as in, it's not *probability*, it's *certainty*)
for RNG systems, you'll have a spectrum of all possible values before you see a pattern.
with a seed based system, you'll see the pattern before you go through the whole spectrum of values.

most "random" generators out there actually use a seed based on the machine's clock.
since time can only go forward, you'll never experience the same output, because you'll never start from the same seed, because .... well.... time can only go forward.
look into that technique.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,087
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
Yea, the thing is that Math.random is implementation-dependent and does not expose a seed value. :kaoslp:

A popular RNG method is the Mersenne Twister (a.k.a. MT). There's a JavaScript (Node) implementation here:

Based on the documentation, I think you could import that file and a small "patch" as two new plugins? The patch would simply replace your game's existing random function with one that references the new generator, e.g. (untested):
JavaScript:
var $gameRNG = new MersenneTwister();
Math.randomInt = function(max) {
  return Math.floor(max * $gameRNG.random());
};
Then you could initialise the generator with a new seed when needed via a script call, e.g.
JavaScript:
$gameRNG.init_seed(123);
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top