views:

595

answers:

12

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?

A: 

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.

sybreon
A: 

Conway's Game of Life may be a good starting point.

DR
+3  A: 

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.

shoosh
Yeah I was considering something like an Lsystem but most information is for plants, although I've also found city rules, but not space rules.
Robert Gould
+4  A: 

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.

Patrick Cornelissen
Well I'm not totally sure what I want yet :) doing preliminary investigation, but I was planning on using coordinates to seed random generation, so I can be sure to get the same results in the same location
Robert Gould
You should add some randomness nevertheless to get some variance (of course this only applies if you don't depend on a repeatable identical generation of the universe)
Patrick Cornelissen
+2  A: 

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.

Unsliced
Well my goal is an artificial universe similar to our own but not the same, however the idea to download it as 1800 suggests is interesting
Robert Gould
I had thought that the Elite writers had open-sourced their code, but that would be a gravity engine rather than a universe simulator.
Unsliced
+3  A: 

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.

1800 INFORMATION
Very interesting alternative. Need to evaluate datasize though, mmm
Robert Gould
+2  A: 

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.

Jonathan
Yeah naming is terrible, but I think I'll use mostly categoric names for most planets like (A321) and some markov algorithm for say 1% of the interesting areas
Robert Gould
A: 

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

Nick Allen - Tungle139
Ok I should have said simulate a plae shadow of the universe then :)
Robert Gould
+1  A: 

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)

Brian Agnew
Indeed now that you mention it Elite is probably terribly underpowered even for what a mobile phone can handle nowadays.
Robert Gould
Yes (not that I want to denigrate their achievement in any way!)
Brian Agnew
ditto - a great achievement!
divinci
A: 

import universe

Don't forget to import antigravity to handle cosmic inflation.
Andrew Grimm
+8  A: 

You should read up on procedural content generation.

Idea 1

  1. Create a variety of PRNGs that always return the same sequence of numbers when given a duplicate seed.
  2. Create a universe seed number (you can use a standard (P)RNG to do this).
  3. Save this seed.
  4. 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.)
  5. 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!

Jonathan C Dickinson
+1: Keeping the seed for an object constant after creation is important. An early JPL animation of a Saturn flyby had a sparkly moon in it because Jim Blinn forgot to reseed the PRNG before each animation frame was computed. Being on a deadline, it went out as it was, but IIRC he rerendered the frames later and used the mistake (as he often did, actually) as a kickoff point for a lecture.
RBerteig
+3  A: 

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.

Juha Syrjälä