How do games like Minecraft and No Man’s Sky have seemingly “infinite” world expansion, yet their files are not only tangible but quite small?

263 views

I was playing Minecraft the other day and went very, very far from my spawn point and eventually returned home. When I retraced my way back, I couldn’t wrap my head around how the game not only generates the environment but remembers the placement of everything as I return to the same places I had already been. With that in mind, wouldn’t the game be required to remember… an absurd amount of information as the user explores their world? How are the file sizes of these worlds not crazily big?

In: 12

8 Answers

Anonymous 0 Comments

When the chunk is generated, it is added to the save file. I have a Minecraft world that has a 10 GB file because I have gone very far.

Anonymous 0 Comments

In Minecraft, the world is only generated in parts as players approach that individual part for the first time. The result will always be the same for that same location given the same seed and program version, but there’s no need to generate it before it’s approached.

Anonymous 0 Comments

Games like Minecraft generates the world on demand based on a seed value

It’s a pseudo randomizer that makes a unique world, but following certain rules so that you get chunks of blocks (like a lake) side by side instead of totally random blocks that would make no sense.

The seed value is a pseudo random code or string that you can plug into the randomizer to get a random world. Normally this is generated by the game, but you can manually enter one if you want.

The world doesn’t exist until you get close enough to that area, then the game generates it for you.

Storing that information in Minecraft is actually relatively straight forward.

You have to consider that part of the genius of Minecraft is that everything is a block. So you have to consider what is the smallest amount of information that I need to create and store a minecraft world?

You don’t need to store all the pixels of the entire object that is a block, because they are all very similar or identical, so a block can be represented by a single keyboard character in memory.

Most likely every block in the world has a location value in a 3D grid of X,Y,Z with 0,0,0 being the starting block

Each block also contains a value which is the type of block it is, and it’s status.

So a dirt block might have a value of A, a rock block B, etc etc

So the file will be

0,0,0 – A

0,0,1 -B

and so on

That’s a lot of text, but text is very easy to compress.

On top of that the game has to store the location of sprites like baddies and animals, and the player characters.

When the save file is loaded into memory the game loads the assets like the blocks and draws them based on their locations in the save file.

Anonymous 0 Comments

Games like that contain the *instructions* of how to build an infinite world. And then the world gets generated as the player explores it.

A brand new world might only be a few MB in size because you haven’t explored it.

If you explored billions of square blocks in a world, then the world file would be much bigger because then all that space would need to be saved as you interacted with it.

Anonymous 0 Comments

Honestly no man’s sky’s worlds are nowhere near as diverse as other games like minecraft. Most planets are just one biome and there’s not a whole lot of mineable area. It’s just a bunch of set pieces and semi random animal / plant configurations. Most of the specifically detailed content is player created. I run into basically identical stuff on different planets all the time.

Anonymous 0 Comments

The game has instructions on how to build the world instead of the world. It generates that world using the instructions based on the seed you give it. This has been a thing as far bas as the Atari 2600 and the game *River Raid*.

Anonymous 0 Comments

Imagine a maths formula. So something like x = (45+27/2)/17^34y

If Y is always the same, then X is always the same. That’s basically how No Man’s Sky works. It has a formula. It says “Okay, so we’re on planet 3829374 at the coordinates 34, 115. What should this land look like?”.

Anonymous 0 Comments

The game world is generated by mathematical formulas and algorithms. It’s not like developers need to hand-place every square metre of grass or empty space. The process is called [Procedural Generation](https://en.wikipedia.org/wiki/Procedural_generation).

Any deviation from that formula (such as changes made by the player) are persisted in the save file. For complicated things like modifying the landscape, that can get real complex real fast, which is why most games don’t implement it, or limit the amount of change that can be done, or the changes are reset when the player leaves the area. Something like Minecraft is a bit easier because it works in 1 metre cubes, you only need to specify the area of blocks that have been changed/removed. For placing specific objects you only need to store the type of object (usually a simple identifier like a numeric ID) and coordinates for its position.