How is one less random than the other? Does one fall into a predictable pattern?
------------------------------
Omnipotent_Q
"Natural Gas! It gives you... ideas!"
Why isn't (rand()%100); totally random?
Hi, I'm a fairly new programmer, but thought I might as well throw in my comments as well.
You may find a use for a rather interesting mathematical toy called 'hailstone numbers'. Although the idea is very simple hailstone numbers have resisted every mathemeticians attempt to predict their properties from a single starting number. Heres how they work...
From your beginning number (which is an integer of any value), lets call it X- if X is odd do (X x 3 + 1), if X is even do (X / 2), to produce a new value, then apply the rules to the new number to produce the next number and so on. Do this until X is 1. Writing a hailstone function would take 5 minutes.
You will get a long sting of numbers of unpredictable length, with unpredictable maximum and minimum values before eventually getting to 1. The same starting number will produce the same series of values. e.g. starting with 13 as X, you get 40, 20, 10, 5, 16, 8, 4, 2, 1. Try it with 27 as X..
Jon
p.s. very interesting about saving the seeding number in the srand() function and its use in Elite. I always wondered how the hell they squeezed a whole galaxy onto a couple of discs...
Edited by - jonpolly99 on October 17, 2001 1:14:37 PM
You may find a use for a rather interesting mathematical toy called 'hailstone numbers'. Although the idea is very simple hailstone numbers have resisted every mathemeticians attempt to predict their properties from a single starting number. Heres how they work...
From your beginning number (which is an integer of any value), lets call it X- if X is odd do (X x 3 + 1), if X is even do (X / 2), to produce a new value, then apply the rules to the new number to produce the next number and so on. Do this until X is 1. Writing a hailstone function would take 5 minutes.
You will get a long sting of numbers of unpredictable length, with unpredictable maximum and minimum values before eventually getting to 1. The same starting number will produce the same series of values. e.g. starting with 13 as X, you get 40, 20, 10, 5, 16, 8, 4, 2, 1. Try it with 27 as X..
Jon
p.s. very interesting about saving the seeding number in the srand() function and its use in Elite. I always wondered how the hell they squeezed a whole galaxy onto a couple of discs...
Edited by - jonpolly99 on October 17, 2001 1:14:37 PM
quote:Original post by Null and Void
Really? Now I have to go look at the CD (it doesn''t seem to be installed with the typical setting) .
I always install everything. Anyway, I have seen it in an installation of VS6 Enterprise and VS.NET Professional. Maybe the standard version doesnt have it, I dont know(Thats what Borland does; the VCL source is supplied only with the Pro and Enterprise versions).
"A society without religion is like a crazed psychopath without a loaded .45"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement