Sign in to follow this  
Telcontar

Storing Player Changes to Procedurally Generated Worlds

Recommended Posts

I love procedurally generated worlds in games. Dwarf Fortress, Terraria, Minecraft, etc etc have all shown that they can be beautiful and evocative playgrounds. I understand the math behind them pretty well (or at least, I understand how to use the various libraries which implement the math) but I'm wondering what the "standard" way to store player changes to the world is.

 

Take the simplest example: changes to the terrain. In the games mentioned above the players can dig and construct, heavily altering the world from its originally generated form. Are these changes kept track of in a list, saved and loaded each time the game is played? It seems like that might get prohibitively large (especially for worlds in 3D like DF) Is there some other, more elegant solution?

Share this post


Link to post
Share on other sites

Minecraft stores modified chunks, in full, on the disk and loads them when the chunk is needed again. So in order words, once a part of the procedurally generated world is modified and this modification cannot be deduced from the procedural system itself, that part of the world needs to be saved and is no longer procedural.

Share this post


Link to post
Share on other sites

Ah hah. Actually that strategy will probably work better in minecraft than in the game I'm designing, where modifying the terrain is a bit harder. I suppose I could use a two-tiered system, where terrain changes are handled like that but stuff like moving objects around or cutting trees doesn't remove a chunk from the "pure procedural" set. Thanks for the info.

Share this post


Link to post
Share on other sites

In addition to switching the whole chunk to stored rather than procedural, you could always store changes as a set of diffs that are applied to the chunk after generation. Either store every atomic change (change this block from dirt to open, etc) you could compress it by storing the events that occurred to create the change, and apply those events in order when recreating the chunk. (ie, apply an explosion radius 6 at (X,Y), dig at (X,Y), etc...) Once the diff starts to affect a certain arbitrary threshold percentage of the chunk, then you could switch to just storing the entire chunk as is, discarding the diff table. This way, you would see some memory savings on slightly-modified chunks, without incurring the bloat of a heavily modified chunk.

Share this post


Link to post
Share on other sites

Minecraft stores modified chunks, in full, on the disk and loads them when the chunk is needed again. So in order words, once a part of the procedurally generated world is modified and this modification cannot be deduced from the procedural system itself, that part of the world needs to be saved and is no longer procedural.

What is meant to be on the disk? Like reading a file?

Share this post


Link to post
Share on other sites

in CAVEMAN,

 

http://www.gamedev.net/blog/1646/entry-2256316-caveman-v30-general-desciption/

 

the procedurally generated world map is 500x500 map squares. a map square is 26400x26400 d3d units. a terrain chunk is 300x300 d3d units. the scale is 1 foot = 1 d3d unit. so a map square is 5x5 miles, and the world is 2500x2500 miles in size. four tile-able "pattern maps" of 800x800 d3d units in size are used to specify the location of trees, rocks, plants etc.

 

user modifications consist of building structures, which automatically clears vegetation. buildings are stored in the list of world objects, or in the list of players, in the case of their personal "house".  

 

the world is generated once and loaded and saved when you load or save a game. changes (buildings that have been built) are also loaded and saved with your game (procedurally generated, persistent, modifiable, open world).

 

terrain chunks are generated on the fly as needed from the world map and pattern maps. in the process of generating a chunk, the list of world objects and list of players is checked for buildings in the way. any plants in the way of a building are not added to the chunk.

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this