Game Development Community

How Random is Random?

by Glen Farrell · in General Discussion · 02/06/2004 (10:06 am) · 5 replies

OK, I know that computer generated random numbers are not truly random - give a computer the same seed and it will generate the same series of numbers.

What I'm wondering is how universal is that?

In other words, say I was to generate a series of random numbers on my laptop, which is running Windows XP. If I were then to generate this series (using the same seed) on a different computer, can I count on getting the same result? Even if it were running a completely different OS like Mac or Linux?

#1
02/06/2004 (10:20 am)
Different C libraries (different OSes for sure, but occasionally even different revs of the same OS) will use different algorithms for the rand() family of functions.

So if you want a rand that generates all the same values cross platform, you should code your own.

If you need source for your own random function, one good resource is the homepage for the Mersenne twister algorithm, which is a pretty good, pretty fast pseudo-random generator.
#2
02/06/2004 (10:41 am)
Thanks Mark! I thought I might run into problems with different OS's, but don't currently have a Mac or Linux box to try it on. I hadn't even considered writing my own - I'll have a look at the Mersenne twister algorithm, see if I can get that working ...

For the game I'm thinking about, it'll cut down considerably on network traffic. Instead of having the server determine computer actions, and sending that to every client, I can have each client determine that action on it's own. So only human actions would need to be sent over the network.
#3
02/06/2004 (10:46 am)
If you haven't been exposed to the terms yet, be sure to look up 'dead reckoning' and 'predictive contracts.' I think you'll find the ideas quite interesting.

Here's another link to get you started.
#4
02/06/2004 (11:17 am)
Using the same seed you can do this with the Mersenne.

the Mersenne rocks.
use it all the time, government lottery corperations are ok with it too.
#5
02/06/2004 (11:38 am)
My preference (and therefor what I'll be making!) is TBS (turn-based-strategy) games. So there's really no lag issues to deal with right now. But there will be a lot going on that the computer needs to calculate. Not just for computer players, but also the actions of 'people' in the human player's empire.

I may have to come back to things like 'dead reckoning' and 'predicative contracts' though - Ultimately I'd prefer turn-based strategy with real-time combat. But I'm not going to worry about that for my first game ...