Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Client-server RTS lockstep


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
3 replies to this topic

#1 polyfrag   Crossbones+   -  Reputation: 1875

Like
0Likes
Like

Posted 08 June 2013 - 12:05 AM

Am I right that client-server lockstep would require commands to be executed 4 turns (800ms) after they were issued?

 

Turn 1: client sends out move command

Turn 2: server receives, acknowledges, and sends out command to other clients

Turn 3: every client acknowledges it

Turn 4: server sends the all-clear to execute scheduled commands and increment turn



Sponsor:

#2 hplus0603   Moderators   -  Reputation: 5538

Like
2Likes
Like

Posted 08 June 2013 - 04:00 PM

The commands are executed X turns after they are issued, where X depends on transmission latency and size of turns.<br /><br />A client acknowledge and all-clear is not needed, btw. Client sends command for turn X to server. Once server has commands for turn X from all clients, it bundles them up and sends them to all clients. As soon as a client gets commands for turn X, it knows it can execute turn X.
enum Bool { True, False, FileNotFound };

#3 slicer4ever   Crossbones+   -  Reputation: 3948

Like
0Likes
Like

Posted 15 June 2013 - 01:35 PM

so, i've been thinking of this problem as well. and my solution is similar to Polyfrags.

1. recieve input from client.
2. predict when all clients should receive the command based on known pings, and mark the command for execution then.
3. distribute command to all clients(including source client, since the commands execution window is changed).
4. recieve OK from all clients.
5. send-all clear to clients.

however, are you suggesting steps 4/5 can be assumed to be received by the clients, and the server doesn't require validation from the clients.
i've been thinking it might be reasonable, since it's possible to detect if a client is out-of sync. however my mechanism suffers from the potential of a sudden lag spike. this might not be a problem over a lan, but over the internet it could be a serious issue.

also, step 5 is problematic, because what-if the all-clear doesn't reach some clients in time for the command to be executed, and then they are out of sync.(similarly stopping at step 3 gives the same potential to occur).

I suppose lag is theoretically unavoidable, but my main concern is how to mitigate recovery, if a client get's out of sync, it'd be hard to get them back in-sync, one method would be to store snapshots of the game at various intervals, and then move back to the nearest interval where a command was run. speed the game back upto realtime, and continue forward. but that seems like a nasty/bloated method for recovery.

Edited by slicer4ever, 15 June 2013 - 01:40 PM.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#4 hplus0603   Moderators   -  Reputation: 5538

Like
1Likes
Like

Posted 15 June 2013 - 11:09 PM

You are not out of sync if, when doing simulation for step number X, you have all the inputs from all the clients for step X.

 

The server cannot send out all commands for step X until it has received messages from all clients regarding step X.

 

Once a client has sent its commands for step X, it cannot change its mind -- it has to "commit."

 

The server needs to detect when data is missing from some client for step X, and not execute the commands, or forward the inputs, until that client catches up. Simple case, the game simulation (not necessarily display!) will lag a little bit. Worst case, the game has to pause while that client catches up, or is determined to have dropped. You have likely seen this happen to RTS games like Starcraft, etc. Suddenly, the game pauses, saying "waiting for player P to catch up."

 

Clients run the simulation for step X once it gets the command packet for step X. Server runs the simulation for step X and forwards commands to all clients once it has gotten all the inputs for step X. While client is waiting for the command packet for step X, it sends commands timestamped for step X+N, where N is determined based on single round-trip latency (round up.)

 

As long as you do lock-step, both the client and the server is actually very, very simple. You don't need any "go-ahead" signals or additional round-trips. All you need is to set the command send-ahead time on the client to the longest roundtrip latency that particular client is expected to see -- or, if you want a "fair" game, set the send-ahead time to the maximum round-trip-time of any player in the game.

 

Typically, when you do lock-step, you also use TCP for transport, as the in-order, re-transmitting behavior of TCP is pretty well matched to the needs of lock-step simulation. If you want UDP, then you typically want to duplicate commands for multiple, older, steps, into each packet you send, so that a single dropped packet will be "made up for" by the next packet sent. Typically, you'll make the amount of duplication match the value of N -- send all commands you have pending that haven't yet been received back by the server, properly timestamped (don't change the timestamp of commands when re-sending!)


enum Bool { True, False, FileNotFound };




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