Open PartialCloning opened 6 years ago
Tested Mersenne Twister (std::mt19937)
INT = -13, 0, 13, -7, 10, 6, -9, -14, 9, -11, -8, -5, 0, 7, 10, 10 REAL = -9.73, 10.94, -15.11, -14.70, -13.85, -3.49, -5.18, 2.96, -9.95, 4.09, 13.67, 3.87, -6.42, -6.23, -7.89, -6.28
So Mersenne Twister isn't much more better in my opinion.
Repeating numbers aren't a sign of a bad algorithm, that's not how random number generators are tested.
I'm not searching for some algorithm that isn't repeating numbers.
I know that M.T. method is better but the differences aren't huge though.
Besides, I would definetely agree implementing M.T. into AMXX.
random_num(0, 255)
:
random_num(0, 1)
:
random(256)
:
random(2)
:
You can try what HamletEagle suggested to try the RandomX module https://forums.alliedmods.net/showpost.php?p=2613505&postcount=11
AMXX can also add SM's M.T. generator but I strongly recommend that random, random_num and random_float functions will be the same as they actualy are.
@ClaudiuHKS as you can see from pictures random
isn't so good.
Oh my.. I've always thought that..
#define random( x ) random_num ( 0, x )
You're right..
It's probably best to just add a new function for a CSPRNG
@ClaudiuHKS
#define random( x ) random_num ( 0, x )
#define random( x ) random_num ( 0, ( x ) - 1 )
of course.
@WPMGPRoSToTeMa can you post a picture showing how different RandomX's or SourceMod's PRNG looks? Do you think such a feature is needed or is random_num good enough?
@PartialCloning I think picture is only a minimal test, we need to make additional tests.
If you do something like this (just an example):
public void OnMapStart() { for(int i = 1; i <= 3; fake++) { LogMessage("%i", GetRandomInt(0, 148)); } }
and just keep restarting server, it will almost always log the same 3 numbers.
(I've tested this only on one server).
EDIT: sorry, now I see it's amx topic.
Will this ever be addressed?
The current random number generators are not that random.
I have no data to back that claim but I'm not the only person to notice a pattern. A forum search shows many posts making the same claim.
In 2005, "Twilight Suzuka" released a better random number generator for AMXMODX, Module: RandomX using the Mersenne Twister PRNG.
In 2009 "altex" reported a bug in the random number generator used in Sourcemod (Bug #3831). Mersenne Twister PRNG based random number generators GetURandomInt and GetURandomFloat were then added to SourceMod. Commit: Added better random number generator.
Possible Solutions: