Tiledata management

I've been trying to create a grid-based open world game. In order to do that I've decided to create a personal map editor. The problem I've encountered is handling data because of the actual data size. For example if I were to have a 2.000x2.000 world, I'd have a total of 4.000.000 grid cells (tiles).

Now then, if we assume that each cell can hold the following:

1. ground image,
2. an add-on on top of that image (something like a flower, or any type of decoration),
3. a wall or anything like that, a box, a tree, etc
4. an add-on on top of a wall (a torch, spiderweb, etc)

And if we assume that each of those takes up to 8 bits (basically that id takes a stored ID from 0 - 255) it would take a total of 2.000*2.000*32 bits of data, which is equivalent to 125 megabytes to store a map of that size. Now then, the size itself isn't a problem if I were to have only 1 floor (you can look at floors as z-axis). But what if I wanted to have several floors? The size would be equivalent to 125*floor megabytes which gets ridiculous over time.

My question would be, what do you think would be the best way to store this type of data, or tiledata in general when working with maps which have enormous size?

• 2000 * 2000 * 32 bits = 128000000 bits, which according to Google is 16 megabytes. Or am I calculating something wrong myself?
– user35344
Aug 11, 2018 at 17:09

2.000*2.000*32 bits of data, which is equivalent to 125 megabytes

First, let's use the correct units. You want to talk about mebibytes, not megabytes, as mebibytes is to a power of 2 value, proper to use with octal systems (which is what we use).

Second, 2000×2000×4 results in 15.26 MiB. Small value.

Now, the real problem:

But what if I wanted to have several floors?

Let's say you have 128 floors. The result of 2000×2000×4×128 will be 1.91 GiB. Quite big, uh?

This might be a problem depending on how your game plays. What some games do is only load a part of the map from disk. This is what Minecraft does, for example. When the player moves, part of the map is unloaded and other part of the map is loaded. This is the best approach if your game doesn't require to simulate the NPCs outside of the player radius.

But, what if the NPCs must be simulated even if outside of the player radius? Well, then the option is really to have the whole map loaded. If you are offering such vast open world to your players, I don't think they will complain about requiring some minimum GiB of RAM to run your game.