Getting truly random numbers is not simple. Proper random number generators have to spend quite a bit of time gathering what's known as "entropy" which is then used to generate random numbers, and even then they are not mathematically perfect. For the most part, people settle for pseudo-random.
That said, 15 seconds on Google turned up a whole bunch of pseudo-random number generators for the PIC. Try something like https://www.phanderson.com/PIC/16C84/random.html and see if you're happy with the results.
As stated, True random numbers from machines are near impossible, or at least incredibly complex. Many of the machines that generate "random" numbers use a sort of medium to get a random value, such as pudding or custard.
Because the game may involve the player pressing buttons, you could get a fairly random number by just reading the value of a fast cycling counter whenever a button is pressed.
The Jan 08 Nuts and Volts has an article on the Microchip uDice board. So check out the random number algorithm there (coding is in C). Or perhaps check the uDice docs at Microchip, they usually have asm code.
Because the game may involve the player pressing buttons, you could get a fairly random number by just reading the value of a fast cycling counter whenever a button is pressed.
Because the game may involve the player pressing buttons, you could get a fairly random number by just reading the value of a fast cycling counter whenever a button is pressed.
Very true. With a counter that is counting in the millionths of a second, it is impossible for the player (unless he hacks the thing) to influence the results.
Very true. With a counter that is counting in the millionths of a second, it is impossible for the player (unless he hacks the thing) to influence the results.