Opened 5 years ago

Last modified 4 months ago

#3261 new enhancement

Rewinding replays

Reported by: elexis Owned by:
Priority: Nice to Have Milestone: Backlog
Component: Core engine Keywords:
Cc: Krinkle Patch:

Description (last modified by Imarok)

While a game is replayed (see #9), the following elements should be displayed in a panel:

  • Button: play / pause
  • Dropdown: replay speed
  • Scrollbar (time axis, optionally markers to jump to different positions)
  • 2 Labels (current time and total duration of the game)
  • Button: open file selection menu (see #3258)

As of r16665, the play/pause function is already implemented. Different game speeds as well (see game_speeds.json, you can't change them ingame yet.)

The most effort would be in implementing the rewind feature (jumping to different places in the replay). This might be done in another ticket, if the other features described above are implemented.

There is the time-warp mode in the developers overlay that frequently serializes the simulation state. Savegames also work on loading the serialized simulation state. Rewinding would require the same method. However, since serializing the whole simulation state takes quite some processing time and memory, serialization should only happen a few times, like every 5 minutes of the match.

An unzipped savegame takes about 10-30MB, but it can be stored using zip compression with about 1 to 8 compression ratio. My 12 largest compressed savegames consume 19,3MB of disk space. This means it should be feasible to save every 5 minutes.

There are three ideas when to serialize the simulation state:

  • While playing the actual game. (Might have too big performance impact)
  • Before the replay starts. It should be done non-visually then, similar to the -replay -ooslog command line option.
  • While replaying the game. Each time a checkpoint is reached, the game would have to serialize.

Philip also suggested that templates shouldn't be in the simulation state, in order to further increase the performance and space complexity of serialization.


The total duration of the game can be computed currently by multiplying the turn length with the total number of turns. In future versions of the game, the turn length might change dynamically though. However if that serialization described above is done, data like that can be extracted from the state of the last turn, saved to a file and enrich the visual replay experience.

Attachments (1)

t3261_savegame_checkpoints_wip_v0.01.patch (14.4 KB) - added by elexis 3 years ago.
Writes a savegame every 5 minutes of ingame time.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 3 years ago by elexis

Priority: If Time PermitsNice to Have
Summary: Visual Replay - session panel (pause / fast forward / rewind)Rewinding replays

comment:2 Changed 3 years ago by elexis

Component: UI & SimulationCore engine

Changed 3 years ago by elexis

Writes a savegame every 5 minutes of ingame time.

comment:3 Changed 3 years ago by elexis

Basic:

  • Optionally write savestates ingame and/or in replays
  • Dropdown to load savestates in replays
  • Continue to process replay commands after deserializing
  • Replay menu button to delete all savepoints of the selected or all replays

Advanced:

  • Slider (#2593) with a marker for every savepoint and player defeat
  • Automatically fast forwarding to the selected time after deserializing
  • Keeping additional savestates in the RAM (potentially using time-warp mode r8803)
  • GUI with pause, play, stop, skip (deserialize previous/next state), fast forward buttons
  • Replay menu column to show the filesize of each replay directory
  • Button to add savepoints of arbitrary places the timeline

More:

  • Replay menu button to create savepoints for a selected replay without visually replaying it

comment:4 Changed 23 months ago by Imarok

Description: modified (diff)

duped by #4921

comment:5 Changed 4 months ago by Krinkle

Cc: Krinkle added

comment:6 Changed 4 months ago by Krinkle

A workaround (for developers) is to use the timewarp/rewind feature:

  • Open the developer overlay (Alt+D, or Alt+Shift+D per #5551).
  • Tick "Timewarp" feature.
  • Use Backspace to go back a few turns.

This is not very flexible and is buggy at times (in particular, once you've used Space to jump forward, it seems BackSpace? becomes rather unpredictable). But, better than nothing :)

Note: See TracTickets for help on using tickets.