Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

It seems to me if that were the case that your directory of saved binaries or serialized objects could get massive real quick. Is there some sort of strategy being employed on top of the State pattern that is optimizing each time stamped saved game so that it isn't saving the entire game "context" all the time?

share|improve this question
1  
What does the State pattern have to do with this? (Or, what do you think it would have to do with it?) There doesn't necessarily have to be a pattern involved at all. –  Kylotan Apr 9 '11 at 11:09
    
Most saved game data from what I've researched is from an object in state (using the State pattern). The object maintains its state so that when it is saved it can be serialized without a lot of hassle. It was just an observation. –  Brian Reindel Apr 9 '11 at 15:38
    
All games and objects have state, but that's very rarely using the State pattern as such. More often you just have write and read functions to save and restore whatever state the object has. –  Kylotan Apr 9 '11 at 17:07

3 Answers 3

up vote 11 down vote accepted

Remember that all you need to save is the dynamic data generated at runtime. For example, if you have a monster about to attack the player, you need to save its position, its monster type, and its aggressive state, but you don't need to save its textures, model, behavioural scripts, and so on, because they are part of the static state that can be inferred from the monster type.

As long as your system keeps a clear distinction between the dynamic properties of the game state and the static properties of the world, there is usually not all that much data to store.

share|improve this answer

One other aspect of game saving is that you really don't need to save anything that hasn't changed. Say you've got a room full of objects if the player enters the room but doesn't manipulate anything you don't need to bother saving the positions of those objects. So you when you're saving the game you could compare the object's default and current attributes and only save the delta. Obviously the comparisons would add complexity and overhead to the process but that's a typical CS trade off, storage or CPU.

share|improve this answer

I think you may be over estimating the size of that data and/or underestimating the size of what is saved. Taking a quick look, I see saves in my folder ranging from about 400kb to 3mb, with one outlier of 8.5mb

What can you fit in 400k? Well, to store the position and orientation of an object in 3d space you would probably use 24 bytes (32 bit floating point numbers for x, y, z, yaw, pitch, roll). That fits into 400k over 17,000 times. Obviously there is more to each object than that, but not much. Keep in mind that you are only storing dynamic objects for the level you are currently on, since you never move backwards to revisit old levels. If you think about it, there are probably no more than a couple hundred objects on each level, most of which are very simple, like physics objects or health/ammo pickups, which probably don't need anything more than the previously mentioned position/orientation and their type.

As example that I'm more intimately familiar with, a ~15mb file can hold all the data you need to recreate an hour of game play in Heroes of Newerth. The exact size/time varies depending on the particulars of the match, but what you have there is the initial state of the entire game, plus the changes between each frame and its previous frame. That is a complete game state (minus unchanged data) every 50 milliseconds!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.