I will add infinite maps, here’s the plan:

First up is a bug fix release. There are some annoying bugs in the game at the moment (water, mostly), and some other things could use some tweaking (SIX wheat for a bread!?). I will try to add some neat toy or so in this release.

After that, I make a big fat copy of the source code so I can revert any changes I make.

Then I split the rendering and game logic up to works with chunks instead of requiring the entire level. For many things, this is possible with a few minor tweaks, for others it will require quite a lot of work. I will get probably end up making water infinite while I do this since the finite water has a LOT of non-locality.

The biggest part of this is to split the level out into chunks. They might end up being 16^3 blocks, like the rendering chunks already are. That’d let me re-use some code instead of having two different chunk sizes at the same time, but I’ve got a feeling 16^3 chunks won’t compress very well when cached (it’s just 8kb each, uncompressed, not counting entities and dynamic tiles). Then again, small chunks is good for the networking.. Hmm.

After temporarily getting rid of ALL entities, I then make the player’s location be relative to the current chunk instead of being relative to the game world. This is to make sure that there aren’t a lot of rounding errors once you’ve moved far away from the “center” of the world.
Then I add all the other entities again.

Once the player can move around in a single layer, I add the chunk fetcher code, which either generates or loads new chunks as they come into view. The very first version of this will just reuse the existing chunks to make an infinitely looping world.
When that works, it’s on to rewriting the level generator to make infinitely large worlds, and add the disk caching of already visited chunks.

Then I release it!

There’s going to be a LOT of work to be done after this initial release of infinite maps, and that release might be a pretty big step backwards in functionality in some aspects (water might not work at all in it, for example), but I think I can reach this first release pretty fast.

I will make it load old levels still, but they’d be surrounded by new infinite terrain that won’t fit in seamlessly to the old map. But hey, that means if you run out of gravel or something, you can run out into the new area to find it! :D

Some numbers and facts, in case you’re interested:

The maximum map size won’t actually be INFINITE in this plan, but rather 4,294,967,295*4,294,967,295*4,294,967,295 chunks. Assuming 16^3 block chunks, that’s a total of 324 nonillion (3.24E32) blocks. You’ll run out of disk space LONG before you run out of map.

Every time you move 16 blocks, a “wall” of (N*2/16)^2 blocks has to be generated, where N is the fog radius. For a fog of 128, that means 256 chunks. At 1 ms each, that’s one quarter of a second. For a fog radius of 256, it’s 1024 chunks. The current fog distances are 512, 128, 32, 8 blocks. It’s very likely 128 will be the maximum with infinite maps.

Each column can have its own sky brightness setting, so daylight changes can be made to roll across the map instead of flipping it all at once. This should be significantly smoother.

Making different areas of different climate is trivial. Huge deserts, oceans and forests.

posted 13 years ago