Page 1 of 1

Do you use rand()?

PostPosted: Fri Oct 27, 2006 1:05 am
by Fuzzy
Can you do without it? TFP wants to know..

There are ways to get around using rand, but if you know them, please dont tell. I am hoping that I may be able to provide some free copies of GE. I just need to talk to Makslane first... so... shush!(but answer the poll!)

PostPosted: Fri Oct 27, 2006 6:17 pm
by Novice
TFP?
It's pretty invaluable to me because i base most of my AI's on rand(); and switches.

PostPosted: Fri Oct 27, 2006 11:32 pm
by DilloDude
I use rand a fair bit. I also made my own pseudo-random number generator where you can input a seed (useful when you want to be able to get the same result), which includes USE_LAST_SEED (use the seed from the last call), and USE_NEXT_SEED (use the result as the seed, generating a sequence).

PostPosted: Sat Oct 28, 2006 12:23 am
by Game A Gogo
HELLL YEAH ITS IMPORTANT, why the question?

PostPosted: Sat Oct 28, 2006 4:42 am
by Fuzzy
Why the question? Because, beleive it or not, you dont need rand() to do a random game.

DilloDude touches on the issue partly. You can write your own random generator, and if you know how, and how it works, you should be able to see that its not truly random either.

A random generated number is simply a sequence that is so long, you cannot see the pattern. There are many other ways to grab a number that appears random.

For example, you could calculate how many seconds(or milliseconds) have past since a certain date.. such as the authors birthday, or any date really, as long as its fairly far back in time.

Another technique, not available to use in GE, would be to take a signal from a port, or to use a system call of some sort to read the fraction from an internal thermometer.

I'll post a simple random number generator on saturday, october 28th..

You should strive to stretch beyond the tools that the authoring system gives you. Like making your own RPG text system, or anything. The journey may be a little harder, but it will pay off in the end!

PostPosted: Sat Oct 28, 2006 5:20 am
by DilloDude
I found some info on pseudo-random number generators:
http://www.math.utah.edu/~pa/Random/Random.html
That's where I got mine from. This shows how some of them work, but you could use many other methods. For example those methods use P1 * x + P2, and mod N from it, but you could have another value (like number of miliseconds) and mod N from that. However, some times you do want to be able to reproduce a random number, like if you have a randomly generated level. Someone might find a level that they like, and then all they'd have to do is remember the seed and put it in when they want to do that level again. Another time this is useful is with file encryption. Basically, find the method the suits what you want to do with it best.