I\'m going to make a space/trading/combat game that is completely procedurally generated. But, I know that storing all of the details of the whole galaxy in memory is unfeas
I suspect the biggest problem you're going to face is having a naming system to name all these objects in a way that's consistent and meaningful to the player -- although we do have schemes for naming real objects systematically. I forget whether Elite's naming convention broke down after a certain point ...
I think it is worth noting, that
a generator that produces the same random-looking output for the same input is called a pseudo random number generator, "PRNG". Typically you give it one "seed" input number at the very beginning and then just pull random numbers from it, calling it without further input. Note: you cannot "go back" to an earlier number, at least not without starting at the beginning.
a PRNG-like function that is called with coordinates as input of each call is typically a "noise" function. Here you do NOT have the "cannot go back" problem - just call with the "earlier" input again. A noise function uses a PRNG (as a backend; or at least it could) which still can be seeded at the very start, so you do not lose your "universe out of one number" feature.
While you could just use a PRNG and combine the galaxy coordinates to a "seed" each time, you would only get "white noise" at best, with no further attributes. A noise function is a much better fit for the job, as it can be chosen or even adjusted to give you tileable/smoothed/spiral-like looking/etc. results. For examples search texture images that were made using perlin noise. I expect you to see that with the same noise function you may create e.g. thousands of random clouds, but by adjusting the noise function to your needs (not just the seed or coordinates), you may get lava or galaxies instead. Adjusting it may not be trivial though.
The number of input coordinates for each call determines the number of dimensions of the noise function, so for a two dimensional map (or texture etc.) you could use a 2-dimensional noise function. Then you call it like noise2d(x,y) each time.
In your situation I would try a 3-dimensional simplex noise function (simplex is from the author of perlin noise, recommended as being better).
Each star system coordinate-triplet then gives you one result number. Next decision would be: what does the number represent? To put the smoothing feature of the simplex noise to good use, I would map lower numbers to emptier solar systems and higher numbers to systems with more mass. Or, maybe better, for each system call simplex noise multiple times with sub-coordinates. Medium sized result numbers then are planets, small numbers are vacuum or asteroids. Big numbers stars, etc.
The topic is not active and it is old but searches may end up here, as mine did.
I use the Mersenne Twister. It is PRNG that accepts as its seed array of any length.
For example, I want to generate galaxy on coordinates x=25,y=72. I re-init twister with seeds [25,72].
If I want to generate 1138th planet in this galaxy, I use [25,72,1138].
Country? [25,72,1138,10]
City? [25,72,1138,10,32]
and so on.
With this method you can generate billions of trillions of zillions of objects using just one number (the one before x coordinate, in our case before 25).
There are some projects now that use it.
Noctis: anynowhere.com/
Infiniverse: http://www.infiniverse-game.com/
If you really want to return to a fixed state, i don't think procedural generation from a single value is the right way to go.
Let's assume, you have a fixed grid of 256x256 systems in each plane and 16 planes in the universe. Each plane has up to 512 trading stations and up to 8 links to other planes. All trading stations and links are on a fixed position. Your initial seed value has to be at least 2^76 to encode all possible universes. Add some more objects (planets, ships,...) and the number grows exponentially.
Edit: It's a bit less if you don't allow more than one trading station or link in each system. I'd use some permanent storage, maybe an embedded database like Firebird or sqlite. Incidentally i'm currently developing such a game.
Take a look at the original Worms game. I think it claimed to have about 4 billion possible levels. Each level was generated based on short seed string of maybe 20 characters. This determined
If you enjoyed a level, you could write down the seed string, and use it to regenerate the same level at a later date.
This is an example of a very complex, but deterministic function, with a single input parameter. I think this is the essential concept of what you need.
Here's the basic idea as I understand it. Say you've arrived in star system #42 and you need to find out what's in it. It has nplanets
planets -- a number between 0 and 10, say:
>>> star_system = 42
>>> nplanets = hash('nplanets%d' % star_system) % (10 + 1)
>>> nplanets
4
OK, so over by planet #2, how many space stations are in orbit there at the start of the game? Find a number between 0 and 3:
>>> planet = 2
>>> nstations = hash('nstations%d/%d' % (star_system, planet)) % (3 + 1)
>>> nstations
1
And so on. The numbers are each a hash function of the indices (star system #42, planet #2, in this case), reduced to the appropriate range. Since hash functions are deterministic but 'random', it's the same each time, but random-looking to the player.
Of course, hashing strings with long sequences like 'nstations' in them isn't the fastest possible way to go about it, but it shows the idea.