Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


General advice on making a replay system ?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 vlad2048   Members   -  Reputation: 179

Like
0Likes
Like

Posted 03 May 2011 - 06:36 PM

I've already made the beginning of a 2d (4p max) multiplayer game on ipad. I'm using cocos2d. The games last maximum 1 minute. I want to get a replay of the most epic ones and use them to decorate the front menu (kind of sceensaver function)
I've already done some replay system (for the same game on PC), but they had some problems/bugs. Mainly from a lack of a consistent interface across all the game objects for replays. I know it's very vague sorry.

My question is, do you have any general advice on making a replay system ?

Even if it's stupid advice. Like "implement StartRecord() and StopRecord()", any advice from someone who has implemented one. Like a postmortem on gamasutra would be great

Sponsor:

#2 Hodgman   Moderators   -  Reputation: 31017

Like
3Likes
Like

Posted 03 May 2011 - 06:45 PM

Gamasutra: Developing Your Own Replay System

Previous GDNet topic


#3 Storyyeller   Members   -  Reputation: 212

Like
0Likes
Like

Posted 03 May 2011 - 09:41 PM

I created a replay system my game. In my case, the task was made a lot easier because I'd thought about that feature from the very beginning and the game code design was designed in a way to make replays easy.

If it's not too late, I'd suggest designing your code with this in mind. The most important part is to isolate everything as much as possible. In my case, the main game is encapsulated in a class that has a function which is basically Update(input)
The game only relies on the arguments to the update function and doesn't try to read anything externally. That way you can pass in either inputs from an actual device or prerecorded inputs and everything will work the same. Also, when you start a new game, an entirely new instance of the game class is created, so there's no issues with accidentally forgetting to reset variables or the like.


The biggest problem I had was floating points. It turns out that due to the boneheaded design of the Intel FPU, floating point math is not necessarily deterministic in the sense that the same source code can lead to different results. (I believe that it is deterministic at the machine code level if you're careful with rounding modes, but who wants to program that way?). I discovered that there were actually differences between my game behavior between debug and release builds due to this problem. I ended up linking the debug build of my game to a version of the physics engine compiled in release mode, which made most of the problems go away. It could still theoretically be nondeterminsitic but I have yet to see a problem.
I trust exceptions about as far as I can throw them.

#4 vlad2048   Members   -  Reputation: 179

Like
0Likes
Like

Posted 04 May 2011 - 03:18 AM

Thanks very interesting.
I will go the route of recording the inputs, it's definitely the easiest. And try to make it as seamless as possible in my code. I need to work within the cocos2d framework though but it should be possible

Also the gamasutra article mentions using a stream to avoid having to create data structures. This seems like a brilliant idea, I'll try that

#5 Storyyeller   Members   -  Reputation: 212

Like
0Likes
Like

Posted 04 May 2011 - 12:25 PM

Personally, I just used std::stream and store the (run length encoded) numbers in text form. Binary would save space but it's more complicated to code and it's nice to be able to inspect the replays manually anyway.
I trust exceptions about as far as I can throw them.

#6 alnite   Crossbones+   -  Reputation: 2123

Like
0Likes
Like

Posted 04 May 2011 - 06:24 PM

Without reading the article, or have any prior experience of writing replays, here's what my brain came out with:

1. Fixed-rate framerate. 30fps, or whatever. At least the logic part of your game, if you go with multithreaded.
2. Record all actions with timestamps and frame when they occur. Actions should also record all randomized values.
3. You are going to end up with a long list of actions.
4. Replay them.

#7 Storyyeller   Members   -  Reputation: 212

Like
0Likes
Like

Posted 05 May 2011 - 08:06 AM

Without reading the article, or have any prior experience of writing replays, here's what my brain came out with:

1. Fixed-rate framerate. 30fps, or whatever. At least the logic part of your game, if you go with multithreaded.
2. Record all actions with timestamps and frame when they occur. Actions should also record all randomized values.
3. You are going to end up with a long list of actions.
4. Replay them.


That's the basic idea, but RLE is more efficient than timestamping while being just as easy to implement.
I trust exceptions about as far as I can throw them.

#8 BeerNutts   Crossbones+   -  Reputation: 2978

Like
0Likes
Like

Posted 05 May 2011 - 01:59 PM

My replay system that i used basically stored all the objects on the screen at a fixed time, like every 60 mS. I found minor inconsistencies when using the Input method that and I didn't always get the same replay. So, to guarantee I didn't have that issue, I just stored the location of the objects (as well as when sounds go off). Make sure you squeeze this into as small a format as you can, but, for 1 minute, this shouldn't be that big. You could look at using zlib to compress and uncompress when storing it off.

FWIW, it's really neat, as I would record the last stage of my side-scrolling shoot-em up, and, after you beat the game, while the credits are rolling, it would be replaying the last level in the background. i thought it was awesome :)

GL!
My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

#9 andur   Members   -  Reputation: 613

Like
0Likes
Like

Posted 06 May 2011 - 07:51 PM

I've already made the beginning of a 2d (4p max) multiplayer game on ipad. I'm using cocos2d. The games last maximum 1 minute. I want to get a replay of the most epic ones and use them to decorate the front menu (kind of sceensaver function)
I've already done some replay system (for the same game on PC), but they had some problems/bugs. Mainly from a lack of a consistent interface across all the game objects for replays. I know it's very vague sorry.

My question is, do you have any general advice on making a replay system ?

Even if it's stupid advice. Like "implement StartRecord() and StopRecord()", any advice from someone who has implemented one. Like a postmortem on gamasutra would be great


Since you have a multiplayer game (this assumes its playable over the network and not just local multiplayer), just record the initial game state when you want to start the replay, and record all of the network messages afterwards (both that you send and receive). Playing back the network messages will give you a full replay. If the game only lasts a minute maximum, just always record all of the network messages.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS