So I noticed that "math.random(100)" is not truly random.
I get the same value each time I load the game.
Is there anything else that I should use?
Thanks.
[Done] math.random() question
[Done] math.random() question
Last edited by TheSAguy on Fri May 11, 2018 8:14 pm, edited 1 time in total.
Re: math.random() question
Afaik you can't seed math.random(). You can seed LuaRandomGenerator, but that will still be deterministic.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: math.random() question
It needs to be this way.
It's a deterministic randomness so it will always give same sequence of random numbers.
You can create random generator in lua - you will need to seed it tho. After that it will produce different sequence of numbers but still a deterministic one.
It's needed to make sure that multiplayer stays in synch - each client and server need to roll same numbers.
It's a deterministic randomness so it will always give same sequence of random numbers.
You can create random generator in lua - you will need to seed it tho. After that it will produce different sequence of numbers but still a deterministic one.
It's needed to make sure that multiplayer stays in synch - each client and server need to roll same numbers.
Re: math.random() question
It depends on the map seed and the tick you call it, so using it for runtime operations should be random enoughTheSAguy wrote:So I noticed that "math.random(100)" is not truly random.
I get the same value each time I load the game.
Is there anything else that I should use?
Thanks.
For, say, data stage, or specific scenario (init) uses, you can try to see another generator with some values,
Seeding with the current mods in data stage,
Or the length and value of a players username in script usage etc.