# Best approach to a 100% synchronized action game?

This topic is 4478 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm writing an action game, which'll contain tons of moving and bouncing objects.. The game will run at say 100 fps internally.. Let's say I have 5000 objects.. It's impossible to synchronize 'em all, so I figured I'll go for a synchronized simulation (you know, when all clients do exactly the same thing all the time, like many rts games do).. The player can move left/right, he can jump, he can aim up/down, change weapon, and fire.. One way here would be to more or less send keypresses, and put 1-5 frames delay on them (depending on ping times).. But that might on the other hand make the game feel unresponsive or choppy/laggy.. Then I figured I can send actions/events, and store them, and also store the entire gamestate every x frame.. If I saved every 10th frame, and saved 4 of those copies, I could go back up to 400ms, and modify reality (sortof).. This way, when I fire my gun, I might see it first some ms later, but the bullet would go off at that time anyway.. My question is, do you think this is a good way to go? Do you think it would require too much cpu/ram? Let's say I have a gamestate of 64mb, copying that 10times every second could put pretty heavy load on the ram? Any suggestions and/or better ways of doing this?

##### Share on other sites
I believe a synchronized simulation works like this:

while (1){    Get user input    Send local input packets    Wait for opponent input packets    Process all local and remote inputs    udate logic    render}

you need fast network code.

-me

##### Share on other sites

Lockstep multiplayer using synchronized seeds with a desire for rapid response to player commands is extremely difficult, and depending on how many players and what level of interaction is required, may be effectively impossible.

Also, why are you trying to run the core at 10ms simulation frames? The usual model is to have the simulation running more slowly than the video update.

--Dave

##### Share on other sites
Quote:
 Lockstep multiplayer using synchronized seeds with a desire for rapid response to player commands is extremely difficult, and depending on how many players and what level of interaction is required, may be effectively impossible.

I agree! However, we actually do that, with up to several thousand simultaneous players online. It took a while to get right, though.

Quote:
 Also, why are you trying to run the core at 10ms simulation frames? The usual model is to have the simulation running more slowly than the video update.

That depends on your simulation. If you're doing forward Euler simulation, you typically want a high physics rate to reduce errors. If you're doing penetration-based constraints, then you want a high collision rate to avoid tunneling. (Yes, there are other ways to avoid tunneling, too)

There are lots of viable game approaches with 100 fps physics rates.

##### Share on other sites
To make objects move smoother among other things.. That way they are less likely to miss eachother in air and things like that.. I should add that it's a 2d game.. Using 50 fps for the logic, I figured a oneframe delay would be 20ms.. If I used 100 logic fps, I could use 10ms in lowping scenarios, and I can use 30 or 50 instead of 40 or 60..

I can't change the game design.. This game can be considered an unofficial sequel you see.. The original didn't have network (Liero is the name of the original game)..

As you can see, it's a very difficult task.. My plan is to send all actions to a server, which then sends it out to everyone (including the one who send it).. They then put it in their eventstack.. This way, everyone gets the same messages in the same order.. Then the server says 'this event happends at currentframe+3' for example (there's a framecounter).. This means it could take 30ms or so for a keypress to be happening, which could be a problem.. And that's assuming everyone has 30ms or less in ping to the server, which might not be realistic.. That's when the keeping of the gamestates come in.. I press a key, send a message to the server, and he sends it out to everyone, without adding that 3 to the framecounter.. This means that when the packet arrives, everyone is 3 frames after the keypress.. They then go back to the saved state, add the message, and run the missing frames again until they reach the current time.. Is this possible at all with current systems, or do you have any better ways?

##### Share on other sites
Quote:
 I agree! However, we actually do that, with up to several thousand simultaneous players online. It took a while to get right, though.

You mean the use of a lockstep model for synchronization in There??

Quote:
 Lockstep multiplayer using synchronized seeds with a desire for rapid response to player commands is extremely difficult, and depending on how many players and what level of interaction is required, may be effectively impossible.

Yup, traditional ways of hiding latency / minimize bandwidth consumption like extrapolation would out of the picture... Besides that it would be a costy operation to do prediction for thousands of objects you'd get a lot of rollbacks because of the butterfly effect; a small change can make a big difference in such a system.

The only way to keep things perfectly synchronized would be using a lockstep model. But this would make your game not so real-time on a normal internet connection (100-300ms latency). As long as we're stuck with unrealiable, lagged network connections it will alsways be a tradeoff between consistency / real-time interaction.

They have network support too, I fail to see how you'd need to synchronize thousands of objects in this type of game :)

##### Share on other sites
Because it's 'the right thing to do' in my opinion.. If one object goes wrong, it could create a hole in the map, which another object could then bounce from, and hit a player that shouldn't be hit.. Suddenly, the map is desynced, the health is desynced, and since that player might have died, alot of bullets might get missing for some players.. And since it's very common to get hit several times each frame, you can't really syncronize that either.. Gusanos tries to syncronize the map.. I'm not sure how it's done, but last time I heard anything, it was that it's not realtime, which means one computer can see a hole, and another one a wall at a given frame.. That would also give undesireable effects..

The whole thing is a nightmare.. :p

##### Share on other sites
Quote:
 Original post by DvDmanDTLiero

You mean the Liero? Do you have the original source or are you writing a clone from scrath?

If I can do anything for you, I'd love to help.

##### Share on other sites
The original source was lost in a harddrive crash.. Another Swede (Gliptic) has reverseengineered the original (with the authors permission) though.. I'm not part of that however, so I'm writing it from scratch..

You can definitly help, I have tons of things to do.. I haven't done very much because of this network problem, but I think I have a pretty good framework.. It renders Ok, though a bit slow.. It'll be based around plugins and mods.. If you think you can help, please contact me over msn (dvdmandt@hotmail.com)..

##### Share on other sites
HeHe i was reading the history of Liero, it reads like some myth of lengend! The original source lost! Epic struggle to recreate what was lost! :)

Good Luck!

-ddn

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631431
• Total Posts
3000039
×