Anyone know of a way to do random number generation?
I want to have a dice-rolling circuit, but I don't know how to do the random number. I don't want to use the software-default because I don't know what type of processor I am using.
Random Number
-
- Posts: 458
- Joined: Thu Feb 05, 2004 1:01 am
- Location: Minneapolis, MN
- Contact:
- dacflyer
- Posts: 4749
- Joined: Fri Feb 08, 2002 1:01 am
- Location: USA / North Carolina / Fayetteville
- Contact:
how about these ideas..
http://www.apogeekits.com/dual_electronic_dice.htm
http://www.kpsec.freeuk.com/projects/dice.htm
http://www.quasarelectronics.com/3003.htm
maybe that will work for you..
i have one here that i made long time ago, it was a radio shack kit..
from way back,
maybe i might still have the plans on it, i'll look in my archives
http://www.apogeekits.com/dual_electronic_dice.htm
http://www.kpsec.freeuk.com/projects/dice.htm
http://www.quasarelectronics.com/3003.htm
maybe that will work for you..
i have one here that i made long time ago, it was a radio shack kit..
from way back,
maybe i might still have the plans on it, i'll look in my archives
Random number generation does not have much to do with the type of CPU you're using. You can perform some form of RNG on any CPU. There are a lot of approaches to getting a truly random value, and it works best if you're able to somehow tie that to an "external" event. For example, upon power up the CPU could run a counter. When an external event (someone pushing a button?) occurs, reverse the counter direction and/or XOR it with a saved value.
When you need the random number, just use some of the bits of the counter. For dice, you'll only need 3 bits (which is a count of 0-7), but they can be any 3 bits from a larger counter.
If you don't have truly external events to trigger from, there are some algorithms out there which can give you psuedo random results. They could generate 1000s of values before repeating; something no one would realize is not random.
When you need the random number, just use some of the bits of the counter. For dice, you'll only need 3 bits (which is a count of 0-7), but they can be any 3 bits from a larger counter.
If you don't have truly external events to trigger from, there are some algorithms out there which can give you psuedo random results. They could generate 1000s of values before repeating; something no one would realize is not random.
Running counters that are read when a button is pushed or released is
the ONLY possible true random number generator. All pseudorandom
number generator routines are actually bizarre and predictable counters,
which simply don't count in order and also eventually repeat when they
overflow. At best, PRNGs are like calculating digits of Pi, which always
remain the same, but are "fair" (as in 'unloaded dice').
the ONLY possible true random number generator. All pseudorandom
number generator routines are actually bizarre and predictable counters,
which simply don't count in order and also eventually repeat when they
overflow. At best, PRNGs are like calculating digits of Pi, which always
remain the same, but are "fair" (as in 'unloaded dice').
Who is online
Users browsing this forum: Majestic-12 [Bot] and 54 guests