

If you use a proper generator like the one I described, you can just make successive calls to get as many random numbers as you want, but you run into the problem of sequential correlation, where each number depends in some predictable way on the previous. Well it depends how good you want your random numbers to be. : other processes in the loop, some kind of rand storage might be required
#ASSEMBLY X86 RANDOM COLOR GENERATOR UPDATE#
: many rands in a short period of time to update data then moves on to : But that only gives 18 rands per second & if the program requires : I'm thinking an 18.2065hz hook INT 1Ch routine timer that also increments a couple declaired Dwords in the. : The timer running Rand constantly is great info.Thankx The high half of the product is your random integer.Įg for an integer random number in the range 0.51 - useful for card games - using the above 32 bit RNG: Then multiply this by (K+1) with an NxN bit multiply. To get an integer random number in the range 0.K, first get yourself a binary N-bit random number in the range 0.2^N-1 - ie for 16 bits, in the range 0000-FFFF. It's not worth buying the book but you can find it in most academic libraries. I got it originally from Knuth, Art of Computer Programming, volume 2, where you can read the explanation yourself if you're so inclined. It would take a lot of space to explain why it's good, or how those particular numbers a and c were chosen. If you want an 8-bit random number take the lower 8 bits, for a 16-bit the lower 16, etc. Where in this case a=19660Dh, c=3C6EF35Fh and M is 2^32. Here's a respectable 32 bit linear regression RNG. This way you have a truly random event (the user reaction time) picking one point out of a psuedo-random set. One way to break up patterns, if you're waiting for user input, is to run the RNG constantly off a timer interrupt, then take whatever is the current result when the input occurs. You will always notice patterns if you run a computer RNG long enough, because it always repeats the same sequence. : Then when I used it to make a mixed up Vmode3 attribute screen I noticed some patterns in the 16 background colors? MOV WORD ,AX We have a new seed, so store it

JNZ GOTSEED if new SEED = old SEED, alter SEED MULĝX MUL (8405h * SEED) into dword DX:AX Returns,ĚL = random number between 0-255,

I didn't check AX=word for rand accuracy, & I didn't check it on other computers either. Then when I used it to make a mixed up Vmode3 attribute screen I noticed some patterns in the 16 background colors? I checked the RAND proc belowīy counting each occurance of every number 0-255 and it produced an evenĪmount of each number (except 38?) in 8000 rand's or so, with no appearant pattern.
