Archived

This topic is now archived and is closed to further replies.

Quick Random Number Generator

This topic is 6600 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When a computer produces a random number it is almost certainly bassed on the time. Might be worth you writing your own algorythum bassed on it.

Share this post


Link to post
Share on other sites
A while back I read that they were making new cpu's that could give a random number based on the amount of heat in the chip. Has anyone heard anything more of this?

Share this post


Link to post
Share on other sites
There is a really simple and very quick random number generator to do in asm, based on just multiplying a register by itself after adding something. works best on 8-bit regs like ah,al. i havent got any code but this is off the top of my head:

first:
_asm
{
mov ah,54
mul ah,al
mul ah,bh
}

later:
unsigned char randomnumber;
_asm
{
add ah,7
mul ah,ah
mov randomnumber,ah
}

randomnumber = apparently random number

Share this post


Link to post
Share on other sites
About random number generation in hardware . . .

I heard that some CPU's may have a compute random number instruction. This would make use of a oscillator, spinning down inside the chip. As the CPU gets hotter, it slows down, as it gets cooler, it speeds up. When a random number is needed, the current count in the oscillator is simply read.

Share this post


Link to post
Share on other sites
Does anybody out there know any good algorithms for quickly generating pseudo-random numbers that DOESN'T make use of the rand() function? Something with tables perhaps? I have come up with a few myself, but I would like to know if there are some better ones out there.

Thanks.

Share this post


Link to post
Share on other sites