Do you use rand()?

Talk about making games.

Is rand() vital to you?

Poll ended at Sun Nov 26, 2006 1:05 am

yes
7
54%
no
4
31%
sometimes
2
15%
 
Total votes : 13

Do you use rand()?

Postby Fuzzy » Fri Oct 27, 2006 1:05 am

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!)
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby Novice » Fri Oct 27, 2006 6:17 pm

TFP?
It's pretty invaluable to me because i base most of my AI's on rand(); and switches.
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby DilloDude » Fri Oct 27, 2006 11:32 pm

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).
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby Game A Gogo » Sat Oct 28, 2006 12:23 am

HELLL YEAH ITS IMPORTANT, why the question?
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Fuzzy » Sat Oct 28, 2006 4:42 am

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!
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby DilloDude » Sat Oct 28, 2006 5:20 am

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.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron