Jump to content
  • Advertisement
Sign in to follow this  
tenpoundbear

PRNG and the Cosmos

This topic is 2774 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys,

So I have been reading procedural content generation, particularly in regards to creating something on the scale of the universe/galaxies, and while there are some information out there I am having difficulty finding information on how it is implemented.

Not an accurate one, just one that is 'fun'.

The theory sounds good. But thinking about it I am not sure how it works when applied to my own project .

If I wanted to create a galaxy that contains many star systems, I would do something like...

Start of with a seed...
This would then return a set of seemingly random numbers, eg 12 17 188 2 38 47 88 blah blah blah
How can I turn those numbers into something meaningful, something I can use?

I mean, what would '12' represent?
The number of stars systems in a galaxy?
The position of a star?
Number of moons?

I am not sure how to start off...


Cheers Guys :)

Share this post


Link to post
Share on other sites
Advertisement
Ysaneya has written some very insightful posts in his journal about procedural planet/galaxy generation, that might give you some inspiration:

http://www.gamedev.net/blog/73-journal-of-ysaneya/

Share this post


Link to post
Share on other sites
The best way to get started is to simply think about it as a randomized process of creation. So you want to create a universe. This means that you need to create galaxies. How many? Where? Clearly, those decisions should be random. You just call your PRNG to give you a random number between 1000 and 2000. That's your number of galaxies. Then, for each of those, you call your PRNG to generate random coordinates. And so on. (There are obviously other approaches to placement of galaxies, this is just a particularly simplistic suggestion.)

So you don't actually look at the output stream of the PRNG and explicitly assign a meaning to each bit. Instead, the meaning is assigned implicitly by how your random process makes use of random bits as they come out of the PRNG.

If you want to, you can remember the initial seed used for the PRNG, and when you want to create the same universe again, you simply seed the PRNG with the same number. Since the resulting output sequence of the PRNG will be the same, you will generate exactly the same universe. It only starts getting a bit trickier if you want the ability to generate only a subset of the universe at a time, but I suggest you first get familiar with the easier task of always creating the entire universe at once.

Share this post


Link to post
Share on other sites
Start by breaking up the problem into smaller problems. For instance, in order to create a galaxy, you can start by picking the overall shape of the galaxy and breaking down space into chunks we'll call sectors. There is a seed for the galaxy that allows you to initialize a PRNG so you can have some apparent randomness in how sectors are created. Each sector will have not only an associated volume, but also some high-level parameters (e.g., star density) and a number that will be used as a seed to continue the generation process.


If we are trying to render our galaxy, we can now cull any sectors that don't appear on the current view. For the remaining sectors, we continue the process of breaking them down into smaller entities (say, subsectors). Eventually we'll have a level of this hierarchy that corresponds to a solar system. Now we'll have some volume where the solar system should be and a seed. We initialize a PRNG with that seed and use it to decide how many stars we'll have, how many orbits with something interesting in them, how elliptical the orbits are, what is it that they contain (say, a planetary system or an asteroid belt)... A planetary system may have a couple of similarly-sized bodies (like Pluto and Charon), or a planet and perhaps some moons. Again, use the PRNG to decide these things. Then we are down to generating individual star, planet, moon or asteroid.

So just solve one little problem at a time (galaxy to sectors, sector to subsectors, subsector to solar systems, etc.), make each entity know its limits, a seed for its PRNG and perhaps some parameters determined at the previous level, cull everything your view can't see and continue refining what's left (recursively).

Does that make things any more clear?

Share this post


Link to post
Share on other sites
There was a lot of good discussion and plenty of good links in a recent discussion "looking for procedural game design" -- it's probably worth having a look at the discussion and checking if there are linked resources you haven't yet come across -- in particular some of the links posted by JTippetts might give you a decent starting point.

Hope that helps! smile.gif

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!