I’m trying to find the source for the “Random” class so that I can port it to Python, in order to run Roblox’s random system in Python. Not to be confused with math.random(). Thanks.
I don’t think you can get the source for it. What aspects of Random do you need in Python?
I do believe it is retrievable, as I once knew a person who re-wrote Roblox’s core game functionality api’s (for his workspace specifically), but it is no matter.
As for Random, I am interested in the seed to randomness system. In python, I want to input a given seed such as ‘12345’ and get the same output from :NextInteger() as I would with Roblox’s random. In both cases for the example seed given, both should output the same number, 91. I did research and some sources say it uses Xoshiro’s 128 random method (don’t know the whole name sorry), but it seems that Roblox is not using the same method, or they tweaked it a it to include :NextInteger(), as the original Xoshiro package does not include the :NextInteger() method.
Hope this brings more info!
Depending on how many random numbers you need at one time, you can just record a long list of outputs from a given seed. If you want to fully understand how the numbers are generated that might be a lot harder but its definitely possible. Look into RNG identification papers? If its a general purpose RNG that might be possible. If it’s a cryptographic RNG you might be cooked (have to guess until you are reasonably sure its right).
you can’t see roblox’s libraries
but you have the luau src
Seems to use pcg32 for math.random. That may be a good one to try to see if it’s the same as Random.
Using the source from the math part of the source, I used my resources (ChatGPT) to port the randomness from the Luau Random, into Python. They have the exact same responses (to the extent of my testing) given the same inputs. Here is the Python class that was made:
upon further consideration, i will only be sharing the python port of LUAU’s random by DMs
Thank you all for helping.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.