As a Roblox developer, it is currently too hard to create truly random numbers.
The current pseudo random number generator math.random() has many issues. Even when using a randomseed, the generated numbers are not always pseudo random, and there are some bugs in which duplicate results are returned.
If Roblox is able to address your issue, how would it improve your game and/or your development experience?
In a modern game, random number generation is used quite frequently for things such as choosing random maps, rewards, players, damage, and many other things. As a developer, I need a random number generator that I know is really random. We owe it to the players to provide random results that are as random as possible.
Surely with all your expertise, and with so many proven implementations of random number generators, Roblox should be able to upgrade the math.random() function to something better.
For sure! This needs to be added. My game, even with math.randomseed(tick()), the spin system will keep spinning the same magic abilities in the same order when you rejoin.
Make sure it’s __namecall invoked because fast math is best math!
Also @MapleMarvel I’m fairly sure Lua’s math.random implementation is just Rand() (from C math) wrapped as a Lua function.
Yeah, unfortunately math.randomseed currently turns subsequent calls to math.random into deterministic junk.
That was one of the motivations for the work being done now.
Is math.randomseed doing something that can cause the seed to duplicate accidentally?
I would expect all random algorithms to return the same number series given the same seed, which can be very useful.
Many multiplayer games rely on being able to seed random with a known number and get the same series out of it across clients to keep things in sync. I know Doom and Quake had their own custom random generators for just this reason, to ensure the random stream would be the same for all clients regardless of their platform (they couldn’t rely on the implementation of clib random being the same on Mac, Windows, Linux etc. etc. so they rolled their own).
It also means dynamically generated worlds will create the same world given the same seed every time. You don’t need to store the world, just the seed.
I’ve also worked on more than one project where the random seed was part of bug reports to help reproduce issues.