Take any number that isn't a perfect square (this will be the seed),
Calculate the first digit of it's square root in the base where 0 is the minimum and the base-1 is the maximum number the random number generator can return, and return it as the generated random number.
The next time it's called calculate the next digit, etc.
The square root of any number that isn't a perfect square is an infinite, non-repeating, decimal, so it should be thoroughly random, and should never wrap.
Sound Good?
matt
idea for random number generator...
- matt2jones
- Veteran
- Posts: 80
- Joined: Sat Feb 19, 2005 8:29 am
- Location: elsewhere
- Contact:
idea for random number generator...
Do not mistake Apathy for feeling Content.
http://www.disjointed.cjb.net - Short Storys
http://matt2jones.deviantart.com - Random Art
http://www.freewebs.com/matt2jones - WebComic
http://www.disjointed.cjb.net - Short Storys
http://matt2jones.deviantart.com - Random Art
http://www.freewebs.com/matt2jones - WebComic
-
- Veteran
- Posts: 109
- Joined: Thu Feb 10, 2005 12:38 pm
- matt2jones
- Veteran
- Posts: 80
- Joined: Sat Feb 19, 2005 8:29 am
- Location: elsewhere
- Contact:
Naw, there's an algorithm for getting it digit by digit I saw somewhere, like long division, so you'd just need to store around two numbers to be able to work out next in the sequence, and then you replace those two and repeat it, so you're doing the same number of calculations, with the same sized numbers, each time...So the random sequence is the digits of the root? Ok. that's good, but as you need more and more digits it will become harder and harder to compute them. Might get kinda slow...
Nek: True... But what's the point in learning how something's done, if you can balls it up for yourself?
matt
Do not mistake Apathy for feeling Content.
http://www.disjointed.cjb.net - Short Storys
http://matt2jones.deviantart.com - Random Art
http://www.freewebs.com/matt2jones - WebComic
http://www.disjointed.cjb.net - Short Storys
http://matt2jones.deviantart.com - Random Art
http://www.freewebs.com/matt2jones - WebComic
I think there's a little more to it than that, maybe not. I'd like to see the algorithm. Maybe it's easier with rational numbers, but with irrational numbers like pi and sqr(2), it takes real computing power to get further and further out. That's why it's such a big deal to compute millions of digits of pi. Otherwise, anyone could do it.
--- Zim ---
--- Time flies like an arrow, but fruit flies like a banana ---
--- Time flies like an arrow, but fruit flies like a banana ---