🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Quick Random Number Generator

Started by
3 comments, last by Coolhand 24 years, 7 months ago
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.
Advertisement
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?
Just because the church was wrong doesn't mean Galileo wasn't a heretic.It just means he was a heretic who was right.
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

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.

/* ****************I'm a programar.I'm a programor.I'm a progremer....I write code.**************** */
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.

This topic is closed to new replies.

Advertisement