If I wanted to generate a universe/galaxy like that of Elite or Spore, what would be some good programming reference materials and algorithms to take into account?
I would think that fractals would be a good start. So, maybe some sort of fractal algorithm with some random parameters thrown in for variety.
I would bet on L-Systems to be able to generate something like this.
Ofcourse saying this is like saying "you can write it in C++". L-Systems is a huge subject and you probably need to know what you're doing to get any result at all.
You probably want to create only as much of your universe as you currently need. So I'd go for a generator that is able to generate a new element of the universe based on some rules and a randomized choice of parameters for these rules.
The generator should not need to examine the whole universe to generate a new element. Ideally only a small neighborhood should be sufficient.
Without more details what you wanna do, I don't think you can get much more detailed answers.
Are you trying to generate a new universe or a simulation of ours?
Re-imagining our universe with different fundamental constants would be interesting, but unless you're an astronomy or physics department of a major university, I would imagine it might be beyond most people's skillz.
All these other answers are boring. Why not copy the real thing? You can extract the data from DSS or SuperCOSMOS. Then just turn it into a cool space game. Simple.
I think that the hardest part (and the one which requires most creativity) is likely to be generating interesting, uniquely recognisable names for all the places you will be creating.
It makes me giggle a bit that we think as human beings we are anywhere close to understanding what a universe IS to the point where we think we can start simulating one. I'm not saying It's bad to aim high and attempt to understand such higher level topics, it just makes me giggle
I wouldn't take too much inspiration from the Elite universe. They were built with all the limitations of a 8-bit computer with tiny amounts of memory available. See Elite (particularly the section on technological limitations)
You should read up on procedural content generation.
Idea 1
- Create a variety of PRNGs that always return the same sequence of numbers when given a duplicate seed.
- Create a universe seed number (you can use a standard (P)RNG to do this).
- Save this seed.
- Use the PRNGs that you created to populate the universe with stars and planets. You will need to create at least five properties for each: X,Y,Z,Mass,Seed - add more as you see fit (e.g. Spore would have GroundColor, AtmosphereColor, Temperature, e.t.c.)
- When you draw near to a planet use it's seed to create the heightmap and features on it.
Any changes that the player makes will need to be persisted somewhere. Basically you will need a transactional store (with CRUD operations) to indicate what the player has done.
Tree #44072:
- Eaten
- Deleted
Planet #14325:
- Changed to blue
Idea 2
Instead of using a PNRG to create positions you could use perlin noise. If you create a few image filters (with deterministic outcomes) you could use the results as:
- Star density maps
- Planet seeds
- Properties
By getting really clever you could even create specific filters that could:
- Make stars in the center of galaxies hotter
- Make different types of galaxies
The advantage of this is obviously the speed - you won't be creating or storing (in RAM) the whole universe in one shot (you simply work out the relevant 'quadrant' you are in).
You will obviously still need to store player modifications.
Hope this gives you a good head start!
Well, you can get the actual Elite's trading engine implemented in C. If I remember correctly it contains also the universe generation part minus the graphics part.
The basic idea is that you take a random number generator and seed it with fixed value. Then you build your galaxy/star system based on random values from the generator. After eight hyperspace jumps or so you reseed the generator with the original value.