How do people design the save game feature in large/complex games?

1.14K views

The save game feature seems simple but it’s mind-blowing how it can return the exact state of a game with all elements/events organised in the correct order. Can anyone explain how it works?

In: 668

39 Answers

Anonymous 0 Comments

Let’s imagine a completely arbitrary game and estimate some costs for it.

Let’s take a multipart quest of “go to town, locate person, find person’s lost burrito, return to person, deliver half-eaten burrito to landfill…etc” which can be imagined simply as “step x of 99.” So even though the list looks complicated, if the program writes a “05” somewhere, the game knows you’ve completed the first five steps and can build the world accordingly (person likes you and chooses the nice dialogue options, burrito is not on map, landfill scavenger population is set to “high,” etc.). So our quest state can be stored with two decimal numbers and still have a large impact

player/chest inventory can be more impactful, but still not hard. If you have 16 slots in your inventory and the game has 99 items (plus 00 to represent empty), then an entire inventory can be represented with a mere 32 numbers in a row. Yeah, we probably need to do this for a lot of containers, but sometimes some big games cheat and only calculate container inventory if the player has interacted with it before (this is one reason later game save files are sometimes much bigger than early game ones)

player position can be as simple as “we’re at save point #7”, but let’s assume a more complicated game that requires something like “we’re on map #12 at position (1337,0420)” which is still only 10 numbers. And since NPCs often stay at one point (or have a behavior the game can calculate without relying on a save file), they don’t need to be included in the save files for a lot of games unless they are dead or something. Just save a time variable and know that NPC A is at the bar at that time.

Everything that seems complicated can usually be broken down into just a few numbers with the right kind of forethought, and lots of more complicated things only need some slight input from the save file to construct a drastically different world. As long as you know which block of numbers represent which game info, the game just needs to think a bit to build the world around it.

Putting things in more perspective: this post has about 2800 characters in it. If I converted all of them to numbers and used the rules up above. I could represent 80 16-slot containers of items and 100 different quest states with space left over.

Let’s assume a hefty save file is 100MB (based on a Dyson Sphere Program file I found on my computer). One unicode character is one byte. That means we can store 107,374,182,400 numbers worth of data in the file. Even if our game has something absolutely ridiculous like 1 million quests and 1 billion containers with 16 slots each that fit the above definitions, we’ve barely used a third of our entire save file space, and that’s even ignoring the fact that you can get even more efficient by breaking things down into binary or hexadecimal rather than relying on unicode

You are viewing 1 out of 39 answers, click here to view all answers.