panel-attack / panel-attack

Panel Attack is a free modern puzzle game inspired by popular games such as Tetris Attack and Pokemon Puzzle League while still maintaining authentic mechanics. Arrange colored panels in rows and columns of three or more to match matches that clear. Panels then fall from gravity and can make chains that give bonuses or attack the other player.
http://panelattack.com/
Other
88 stars 36 forks source link

Implement replay controls #50

Open LittleEndu opened 5 years ago

LittleEndu commented 5 years ago

Things like fast forward, rewind, skip to frame number, etc.

As of opening this issue, it had 14 votes (most voted issue having 72)

JamesVanBoxtel commented 2 years ago

Fast forward and frame advance are done

Endaris commented 2 years ago

Missing features: Rewind Skip to frame number

Main problem: Replay files are currently made up of a sequence of inputs, meaning it is not possible to support rewind based on that information as there is no state information that allow the game to find out what happened earlier in the match without restarting the replay.

Possible solutions:

  1. Hacky but doable: Have one stack simulate on fast-forward in the background based on the replay without being rendered in the background and create snapshots at set intervals to make it possible to rewind to these snapshots (or skip forward to them) by creating a copy and replace the instance of the stack visible to the player with it.
  2. Fancy but impossible short to midterm: Change the engine and replay format to have a replay consist not of inputs but instead what actually happens with the stack as state information so that actions can run in both directions. So instead of just having an input "left" for a frame, the replay would store that the player moved from coordinate (x1|y1) to (x2|y1) which is a reversible action. Additionally the engine needs to get overhauled in a way that it can actually understand these instructions to produce rewind effects.

Skip to frame number is certainly possible but would nowadays rather be "skip to time" as frame numbers are no longer visible by default. Additionally there is a big uncertainty of how the UI should look for this as it would require an input dialog of sorts.

JamesVanBoxtel commented 2 years ago

We actually save the state of the whole system in rollbacks. I have a branch that does rewind already... so I'll assign this to me and can post a PR when we are done with major reworks.

Endaris commented 1 year ago

Up to 4s of rewind are possible now. We may want to look into allowing users to configure how much rewind they want for replays. The concerns for this are mainly: Can the CPU comfortably keep up with creating rollbacks? If not, players may want to disable it to avoid stuttering during replay playback. How much RAM is available? Saving more game states is mainly a RAM concern. As a rule of thumb, one second of rewind occupies around 15MB of lua memory. Panel Attack currently caps memory allocated by lua (without assets) at 256MB and enforces garbage collection at higher values. Besides rollback copies, lua memory grows very slowly, at the time of writing around 5MB per 10 minutes in a high gpm 2p vs game. Players could configure a modified RAM cap for replay playback. Based on that we could calculate how many seconds of rewind we can afford. Setting the modified RAM cap to 1GB for instance would already allow ~16s of rewind. Definitely needs a bit of practical testing to see how things turn out in reality though.