freddern 0 Posted May 26, 2003 I was watching the new matrix film then I started to wonder about how computers do choices. Eksample if you are playing a role-playing game and you throw a dice. How does this work? Share this post Link to post Share on other sites
Die Alive 0 Posted May 26, 2003 Ya, my Winamp keeps playing the songs that I choose to play just the day or 2 before. Shuffle my ass. -=Die Alive=- Share this post Link to post Share on other sites
kegetys 2 Posted May 26, 2003 Regular home PC computers can't really do random numbers (as true random numbers cannot be computed by using any algorithm since they wouldnt be random then), only pseudorandom, which all can be "predicted", ie. they are the same every time if you use the same seed. Though usually programs use something varying number (for example the current date/time) as the seed for the random numbers so they will become different on every run. A quote from the net: Quote[/b] ]A true random value is generated by a physical process like a dice throw, counting the particles emitted by the decay of a radioactive element. Pseudo-random numbers are generated by software functions. They are referred to as "pseudo-random" because the sequence of numbers is deterministic. Given a particular function and a "seed" value, the same sequence of numbers will be generated by the function. If the pseudo-random number generation function is well designed, the sequence of numbers will appear to be statistically random. However, there is no question that these numbers were generated by a deterministic process (e.g., the pseudo-random number function). The repeatability of the pseudo-random number sequence can be useful for debugging and simulation, since the program will calculate the same result every time it is run (which would not be true if a true random number generator were used). Some CPU's have random number generators in them but they are rarely used anywhere, and some systems (for example the linux kernel) can generate random numbers by using many different external sources for the numbers, for example by sampling noise from a microphone/line in of a sound card. Real role playing games have little to do with computers btw. :P Share this post Link to post Share on other sites
freddern 0 Posted May 26, 2003 Thanks for the GOOD response. btw: I ment role-playing game on computers like Neverwinter nights. SORRY... Share this post Link to post Share on other sites
WhoCares 0 Posted May 26, 2003 I am not absolutly sure, but I think they use the system clock for this. The system clock is basically a counter that counts the seconds since 1970. As it continues counting, the returned value is always unique. On this value, I think they perform some more or less complex boolean and/or arithmetic operations to get a final result. So the value is not really random, as it is reproducable if you know the time and the function, that was applied to it. Share this post Link to post Share on other sites
bn880 5 Posted May 26, 2003 You see, you ask just about anything on the OFP forums and you can get an answer. And if you look into an OFP mission script you will find: randomSeed=14329347; In general, random is a relative term... especially when it comes to getting a seed. Share this post Link to post Share on other sites
der bastler 0 Posted May 26, 2003 Actually this is the traditional equation to calculate random numbers (remembering good old school Informatik): <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> z = (a * z + c) mod p z: random number a: factor (constant) c: offset (constant) p: module Iterate this sequence and you get a bunch of "random" numbers. If you want random numbers between 0 and 1 (normalized numbers) you have to calculate: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> z_norm = z / p There are some rules how to choose the constants: p > 2^20 Â (sequence repeats after p steps; p should be prime number) 0 <= z <= p-1 sqrt(p) < a < p a mod 4 should equal 3 c mod 2 = 1 (c has to be odd number) Share this post Link to post Share on other sites
bn880 5 Posted May 26, 2003 There are various functions to generate evenly spread numbers based on a seed, this still does not change the fact that there is only one "random" factor, the seed which is usually initiated from the system clock. Either way, it doesn't truly matter if you get a seed from a clock, a microphone, a digital/analog device. Wether you can get from result B to source seed A or not doesn't change much. here is another "random" number generator, but really it is still dependent on that seed: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">/************************** MERSENNE.CPP ******************** AgF 2001-10-18 * * Random Number generator 'Mersenne Twister' * * * * This random number generator is described in the article by * * M. Matsumoto & T. Nishimura, in: * * ACM Transactions on Modeling and Computer Simulation, * * vol. 8, no. 1, 1998, pp. 3-30. * * * * Experts consider this an excellent random number generator. * * * * © 2003 A. Fog. GNU General Public License www.gnu.org/copyleft/gpl.html * *****************************************************************************/ #include "randomc.h" void TRandomMersenne::RandomInit(long int seed) { // re-seed generator unsigned long s = (unsigned long)seed; for (mti = 0; mti < MERS_N; mti++) { s = s * 29943829 - 1; mt[mti] = s;} // detect computer architecture union {double f; unsigned long i[2];} convert; convert.f = 1.0; if (convert.i[1] == 0x3FF00000) Architecture = LITTLE_ENDIAN; else if (convert.i[0] == 0x3FF00000) Architecture = BIG_ENDIAN; else Architecture = NON_IEEE;} unsigned long TRandomMersenne::BRandom() { // generate 32 random bits unsigned long y; if (mti >= MERS_N) { // generate MERS_N words at one time const unsigned long LOWER_MASK = (1LU << MERS_R) - 1; // lower MERS_R bits const unsigned long UPPER_MASK = -1L << MERS_R; // upper (32 - MERS_R) bits int kk, km; for (kk=0, km=MERS_M; kk < MERS_N-1; kk++) { y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); mt[kk] = mt[km] ^ (y >> 1) ^ (-(signed long)(y & 1) & MERS_A); if (++km >= MERS_N) km = 0;} y = (mt[MERS_N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); mt[MERS_N-1] = mt[MERS_M-1] ^ (y >> 1) ^ (-(signed long)(y & 1) & MERS_A); mti = 0;} y = mt[mti++]; // Tempering (May be omitted): y ^= y >> MERS_U; y ^= (y << MERS_S) & MERS_B; y ^= (y << MERS_T) & MERS_C; y ^= y >> MERS_L; return y;} double TRandomMersenne::Random() { // output random float number in the interval 0 <= x < 1 union {double f; unsigned long i[2];} convert; unsigned long r = BRandom(); // get 32 random bits // The fastest way to convert random bits to floating point is as follows: // Set the binary exponent of a floating point number to 1+bias and set // the mantissa to random bits. This will give a random number in the // interval [1,2). Then subtract 1.0 to get a random number in the interval // [0,1). This procedure requires that we know how floating point numbers // are stored. The storing method is tested in function RandomInit and saved // in the variable Architecture. (A PC running Windows or Linux uses // LITTLE_ENDIAN architecture). switch (Architecture) { case LITTLE_ENDIAN: convert.i[0] = r << 20; convert.i[1] = (r >> 12) | 0x3FF00000; return convert.f - 1.0; case BIG_ENDIAN: convert.i[1] = r << 20; convert.i[0] = (r >> 12) | 0x3FF00000; return convert.f - 1.0; case NON_IEEE: default: ;} // This somewhat slower method works for all architectures, including // non-IEEE floating point representation: return (double)r * (1./((double)(unsigned long)(-1L)+1.));} long TRandomMersenne::IRandom(long min, long max) { // output random integer in the interval min <= x <= max long r; r = long((max - min + 1) * Random()) + min; // multiply interval with random and truncate if (r > max) r = max; if (max < min) return 0x80000000; return r;} Share this post Link to post Share on other sites
Devil 0 Posted May 26, 2003 To sum it up, computers do not generate random numbers by themselves, as for they cannot think, and they use a complex algorithmic equation, based on some small factor such as the X and Y coordinates of your mouse, the system time, etc. to calculate a number in the given range. Share this post Link to post Share on other sites
Epita 0 Posted May 26, 2003 Also when there is no need to create numbers as they go along, there are tables of 'Random' numbers produced by universities that are almost 100% random. To use this for a random cd player, just pick up where you left off and loop round when its finished (normmaly a long long time). Share this post Link to post Share on other sites
Guest Posted May 26, 2003 There are true random genarators that are used by special cryptography computers. They are based on a sample of radioactive decaying material and a sensor that measures the time between the bursts of radiation. A more cheap alternative that is also used are huge tables of such measurements. Share this post Link to post Share on other sites
Tex -USMC- 0 Posted May 26, 2003 So, what we're getting at is that the computing power needed to produce truly random results is simply not cost-effective when compared with a simulated 'functionally random' system? Except of course in cryptography, where truly random systems are priceless. Share this post Link to post Share on other sites
bn880 5 Posted May 26, 2003 There are true random genarators that are used by special cryptography computers. They are based on a sample of radioactive decaying material and a sensor that measures the time between the bursts of radiation. This is still not even truly random. If you had the complex means to understand the process, you could predict the next burst of radiation. Okay, it's a huge improvement in human terms, because that is much harder to predict than a crystal oscillator clock. Reality and understanding sometimes create a hard time for us eh. Share this post Link to post Share on other sites
Devil 0 Posted May 26, 2003 Can't fractals be applied to random numbers? Share this post Link to post Share on other sites
Guest Posted May 26, 2003 This is still not even truly random. Â If you had the complex means to understand the process, you could predict the next burst of radiation. Â Â No, we fully understand the process. Its truly random because of the quantum mechanics nature of the decay process. Quote[/b] ]Okay, it's a huge improvement in human terms, because that is much harder to predict than a crystal oscillator clock. Not harder. Impossible. Share this post Link to post Share on other sites
bn880 5 Posted May 26, 2003 I disagree and as I said in other thread, I don't have means to disprove the random part of QM, I simply can't accept it through some sort of mental problem as you think. Share this post Link to post Share on other sites
Guest Posted May 26, 2003 Quote[/b] ]And I don't see anything that makes Einstein see a random effect anywhere. Search the web for Bose-Einstein Here's one for you. It's a favourite in solid state physics (i.e semiconductors): http://hyperphysics.phy-astr.gsu.edu/hbase/quantum/disbe.html Edit btw. Good site in general nice overview of QM and how all is connected. Share this post Link to post Share on other sites
bn880 5 Posted May 26, 2003 OK so, just because some things are equally probable to the way they are observed does not make them truly random. They are equaly probable for a reason. This does not look like any acceptance on Einsteins behalf of some truly random event. For the purpose of a theory a random distribution or equal probablility may be used but that is not acceptance of true randomness. It may be acceptance that the reason for the equal probability is not known. EDIT: I have a sneaking suspicion you do not trust a truly random theory yourself, and are waiting for someone to find the reason for a seemingly random result. Share this post Link to post Share on other sites
Guest Posted May 26, 2003 OK so, just because some things are equally probable to the way they are observed does not make them truly random. Â They are equaly probable for a reason. Â This does not look like any acceptance on Einsteins behalf of some truly random event. Â For the purpose of a theory a random distribution or equal probablility may be used but that is not acceptance of true randomness. Â It may be acceptance that the reason for the equal probability is not known. It's not equal probability like on a dice. In the Bose-Einstein distribution it's exponential. But the point is not in the probability but in the random outcome. A distribution is just a bound for the values. The values inside the bound are however random. You are are entierly confusing things. Say you flip a coin and that the result is random. It doesn't matter that the probability is equal for both sides of the coin - the result is still random. Those are two completely unrelated things. Quote[/b] ]I have a sneaking suspicion you do not trust a truly random theory yourself, and are waiting for someone to find the reason for a seemingly random result. Is my english so bad? It's a fucking fact of nature. I've tried explaining it to you in several ways but you refuse to listen. Share this post Link to post Share on other sites
bn880 5 Posted May 26, 2003 I'm listening and reading a shitload of things, I don't see anything as being random without reason, not without an underlying cause. You can honestly say to me you accept something is truly random, without an underlying cause for one outcome or another? Yeah, I guess I'm in the dark ages. It's allright though, we will have a unified theory to explain everything in no time, no matter what you or I think. Share this post Link to post Share on other sites
Guest Posted May 26, 2003 I'm listening and reading a shitload of things, I don't see anything as being random without reason, not without an underlying cause. Random without a reason? Reason? That's religion not physics. An underlying cause? Of course there is. I told you: The wave/particle duality and quantum energy levels. I see that you are now at least accepting that there are random events. Share this post Link to post Share on other sites
bn880 5 Posted May 26, 2003 If there is a reason for what you call random, it's not really random. It's like saying the computers random() functions are random because they take system clock or audio levels as a seed. Basically, unpredictable is not random. I don't know why you are getting so emotional about this. How do you know it can not be theoretically predicted in the future. Maybe some equation can be added to the QMT to supplement it in the future? And stop butchering me with religion... you think I'm some sort of moron for not accepting the term "random"? I don't think any less of you for believing in it. We are actually not discussing simple things, even if they are at the root of everyhting. EDIT: Okay, is my English so bad? You can substitute cause for reason. Share this post Link to post Share on other sites
Necromancer- 0 Posted May 26, 2003 Some CPU's have random number generators in them but they are rarely used anywhere, and some systems (for example the linux kernel) can generate random numbers by using many different external sources for the numbers, for example by sampling noise from a microphone/line in of a sound card. The first Pacman game used the random number generator of the CPU. Share this post Link to post Share on other sites
NurEinMensch 0 Posted May 26, 2003 I'm with bn880 here. I don't think there are truely random events, but there are alot of events we are not able to predict. Even if we do not know what a system will do, the system itself does know. And the same system under exactly the same conditions will always behave the same way. Getting exactly the same conditions again might mean moving back on the time axis, tho. I cannot prove this, but I think this is the way the universe works. Share this post Link to post Share on other sites
reedkiller 0 Posted May 26, 2003 @ NurEinMensch and bn880 -- Do you realize who and how much work you are arguing with when you say there are no truly random events!? The theorys are so strong that it is not a matter of opinion. Your argument would have some weight if we just looked at the results of things such as radioactive decay and declared that it is random just because it looks random, but that is not the case. We declare it random because we understand the process and can see that randomness is a part of it. In other words we know it is random because of the theory behind it not because of observation. Share this post Link to post Share on other sites