Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChristopher Sea
3,726 PointsHow does RNG work?
I'm still trying to understand how RNG works. Do web browsers use seeds (if I'm using that term correctly) for RNG? Do all web browsers use the same seed? If you flip a coin (digitally speaking), you would normally have a 50-50 chance of it being heads or tails. Is it possible to write a statement that forces those chances to skew one way or the other, i.e., 60-40 or 25-75, if certain conditions are met?
1 Answer
alex novickis
34,894 PointsRNG's and psuedo-RNG's (PRNG) are different things
On most modern computer systems you actually have access to a hardware register that provides a true RNG it's typically based on inherent noise found in a silicon circuit, amplified a lot, and used to drive something like a counter or shifter to collect many bits
PSRNG, are based mathematical operation starting with a seed which can be a unit of time from a clock, or something you enter, or even by accessing your RNG register
usually RNG/PSRNG's return a number with 16, 32, or 64 bits
of course you can write a skewed generator that's conditional
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 Pointschanged from comment to answer