After concern and debate of the Random Class in .NET and knowing from experience the vb6 random was terrible, i found it necessary to create this, i will be using this myself for my next mp3 player.
This DOES NOT use the original Random class in any way, shape or form, i have seen examples of "better" random classes which try to extend the original, which, is practically impossible.
This class is a complete built solution, it uses 4 factors most likely to change:
System Memory (RAM)
Why is this class "more random" than the pre-packaged one you ask?
Because classic random uses just the timer as a seed, and a mathematical pattern to generate from then on, so it will ALWAYS create a pattern
Whereas, this class only follows patterns for a limited time(long enough for new data to come in) and the fact it uses RAM and the Mouse Position means it is effected in a way unknown to the system.
The system clock spins circles, so it will of course create a pattern.
a user moving their mouse is COMLETELY unpredictable.
RAM is effected continuously in ways that can never be predicted(within reason)
CPU performance is effected by everything running and even the weather!thus the CPU can also never be accurately predicted
How did I test the results? (demo is attached)
by creating 2 classes of the classic Random, and 2 classes of TrueRandom
then making all 4 create a list of random numbers
classic random generated 2 IDENTICAL lists every time i tested
whereas the 2 TrueRandom classes would create 2 different lists
multiple of this class, created under all the same conditions returns different results,
that is truely random.
Now that's the background out of the way, below is a screenshot of the test program, the class file, and the source to the demo program.
Was this useful? please comment or rate