how to record and play game input?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: how to record and play game input?

Post by pgimeno »

Xugro wrote: Sat Jun 25, 2022 7:22 pm Is there a problem with the speed of the playback? I am not sure.

Let's assume you have a fast pc and record your game with 60 fps. Then you send the recording to me. I have a slow pc and can only run the game with 30 fps. Since the playback would use the recorded dt's and my slow pc takes twice as long to recalculate everything, I would see the playback with half the original speed - wouldn't I? And I don't see where a timestamp would fix this problem.
I didn't say anything about sending replays :) Well, the OP mentions demos as a possibility so it's something to keep in mind.

Anyway, assuming there's enough idle time for it to run on both systems, it will probably work. Typically the recording program will have vsync on, and have idle time between frames. The replaying program needs to disable vsync (because the monitors are not guaranteed to use the same frame rate), so some tearing and/or stuttering is possible during replays. That's the idea, at least. If the recording program uses 100% CPU, then the replay will certainly run slower in a slower machine.

More than anything, the main use I see for this is to debug, or ask for help with, hard-to-reproduce bugs. I did something like this some time ago to help with a forum post about an intermittent bug, when I faced the challenge of how to debug it in a repeatable way so that I could check what went wrong.
glitchapp
Party member
Posts: 235
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: how to record and play game input?

Post by glitchapp »

well, if you need a game to test such a library I can provide an early version of my game so you don't need to download the heavy assets.

I won't complain if I need to test such a library in my game or be the first implementing it :joker:
Attachments
luasok9.love
(720.43 KiB) Downloaded 64 times
User avatar
knorke
Party member
Posts: 238
Joined: Wed Jul 14, 2010 7:06 pm
Contact:

Re: how to record and play game input?

Post by knorke »

I think the best replay-system depends on the type of game.
This fishgame looks to be:
-grid/tile based
-not real time
-other objects only move when the player pushes them (like sokoban),
there are no physics or enemies that move even when the player is idle (unlike the ghosts in Pacman)

Basically the fishgame is turnbased like chess.
So it would be enough to just record the changes in playermovement.
Inputs that do not result in player movement (like holding down a key when already stuck on a wall) does not need to be recorded.
I think for a puzzle-style game like this, saving time is not necessary either.
Maybe do not even bother do save it as a table but just as a string.
Say you have fish1's movement saved as:
"a"=left, "d"=right, "w"=up, "s"=down
and fish2's movement:
"4"=left, "6"=right, "8"=up, "2"=down

Then a replay might look like this:
aaa88s
which means:
fish1 moved 3 tiles to the left, then fish2 moved up twice, then fish1 moved down one tile.
It is somewhat human-readable and replays can be easily shared.

Nice "old TV screen" shader by the way!
glitchapp
Party member
Posts: 235
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: how to record and play game input?

Post by glitchapp »

Thank you!

I agree with what you said to a degree and that would be better than nothing as a first implementation, but saving time would create a more realistic replay because otherwise every movement will take exactly the same time and it would not look like a real replay or demo.

I think that even for a game like this some kind of time syncing would be desirable so that when you replay it looks like a real person playing the game and not like a robot that takes exactly the same time for every movement.
Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 46 guests