Tony Smith wrote: >>> The problem with the rotate & carry routines is they >>> >> repeat, eg after >> >>> 65k operations (16 bit register). >>> >> Tony: >> >> That property is hardly unique to LFSRs. Since pseudo-random >> number generators are deterministic algorithms run on >> deterministic machines with finite memory, they ALL repeat. >> >> -Andrew >> > > > That's right, which is why I mentioned seeding etc. The algorithm is > possibly the least of your worries. > > Since they repeat, you need some method of jumping around in the sequence. > The Basic 'Randomise Timer' was commonly used as the value of TIMER (system > clock) would change, so the starting point in the sequence would change. OF > course, if the program happened to start at exactly the same time, you get > the same sequence of numbers. > > In a PIC, you'll need to find something like that, typically from the > environment. Like Jinx said, maybe the WDT (temperature sensitive). Hook a > light detector to an ADC. Measure cycles between keypresses and so on. > > Personally, having the PRNG run continuously might be the easiest option. > No guaranted to be random though. > > Tony > > Gaming devices use white noise generators which run all the time. A random number is "pulled" from that hardware device when needed. These random events are created by biasing a specially doped diode, amplifying the signal, and measuring the interval between these quick events. Randomization is the most difficult thing to accomplish for gaming devices, and state gambling boards require independent testing of each slot machine's randomizer before certifying its use. I have seen slot machines pulled for hitting too many jackpots, though; the operators lose confidence in them. --Bob. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist