Skip to main content
GameDev.net gamedev.net
🔒 Locked

Saving/Loading Replays

Started by d000hg Jul 13, 2009 at 12:06 PM 1 replies 1.1k views
Original Post
d000hg
d000hg
I've been thinking over creating such a system and I'm not sure I have the best solution. I'm essentially torn between a centralised & modular system. The first has a "replay saver", which knows what types of data are saved and exposes an API for the game modules to call and a "replay loader", which reads from the file and calls existing APIs to simulate actions being performed. The modular approach means each game system has a ReplayPlayer, registered with a central file reader. The central reader gets a line from the file, determines the registered ReplayPlayer to use, and passes the data... the module then internally figures out how to handle the replay data. While the second approach seems more like proper engineering in some ways, it also could lead to many classes having their own replay code... making replays tightly coupled with the code-base instead of having a replay engine driving the application. Discuss...
swiftcoder
swiftcoder
What is the minimal set of data your game needs to play-back a level?

For instance, if your gameplay is entirely deterministic, it is enough to record only the random seed, and the player actions (along with the time they occurred), and insert them back into the game at the right time.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
LorenzoGatti
LorenzoGatti
I don't know what you mean by "each game system", but your two approaches are fundamentally identical: find every command that needs to be recorded and execute it in the same way as normal gameplay would. This requires, one way or the other, coverage of all entity types and all their possible actions: there's little difference between a centralized replay playback that calls "existing APIs" of game entities and a centralized replay reader that dispatches more opaque data to games entities to replay their own events.

It seems you are too interested in the binary data and file formats you'll use for replays: in practice, you should design a simple text format or a simple database schema (to let you edit replays) or leave binary data to a serialization library.

The serious difficulties are accounting for all possible events, identifying game entities to dispatch replay commands, ensuring deterministic playback and faithful timing, and avoid hardwiring needless details of complex, changing data structures in replay management subsystems.
Omae Wa Mou Shindeiru

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.