On Jul 2, 9:25 pm, Garrison Benson <Benson.Garri
...@gmail.com> wrote:
> I'm working on a [in my opinion] somewhat innovative roguelike game
> for which being able to record and replay games is an important
> feature. But it turns out it's quite a bit more difficult than I
> anticipated. Does anyone have any experience in making it possible to
> record and replay games? Any advice would be appreciated.
I've done something like this for the game I'm working on (not a
roguelike) to implement multiplayer. I save a copy of the game state
every so often and when remote actions are recieved through the
network it reverts to a state from before the action's timestamp,
inserts the action into the queue, then runs forward again to to the
present time taking it into account. Probably not the recommended
method but it works for my purposes and has some advantages: there is
no lag on your own actions, very little information needs to be passed
between players to ensure they have the same state, it's impossible
(well, difficult) to cheat because other players will always be in a
legitimate state - you'll just end up getting out of sync.
Of course all that is really necessary (if it doesn't have to be done
in real-time) is to save the initial state (level, RNG seed, whatever)
and the sequence of actions performed by the players, and the state at
any given time can be recomputed from those.
These are the important parts to make this work as I see it:
- game state is completely encapsulated in one place, and does not
depend on anything else (unless it is guaranteed to be constant).
- RNG state is considered part of the game state.
- the game is completely deterministic. ideally time progresses in
discrete steps.
- all changes to the game state by player actions are carefully
managed and recorded.
If you're planning this from the start it should be very easy to build
it in. If you're a way into the project before adding this it might
get a bit more difficult - the "game state" tends to get scattered
around in a bunch of different variables all over the place, and user
input tends to just directly change values without keeping a record.
I'd recommend using the exact same format for new actions and replayed
actions.
What are you finding difficult?
Sidetrack: One time when I was trying to write a roguelike I had plans
to do something using recorded actions for the final dungeon (which
was to be ridiculously hard). The idea was that you would arrive a
turn or two after your previous character and be able to follow along
behind them and maybe rescue them from whatever killed them (at which
point they would stop following the recorded script and revert to pet
ai) or stupidly get killed by the fireball trap they set off.
Eventually, after several tries, you'd manage to kill the end boss by
climbing over the corpses of your previous characters; then the
challenge would be to try to win with the fewest characters possible.
This would be best on a public server (complete with glorious
opportunities for griefing).