0
\$\begingroup\$

I have a working P2P non real time (think Civ 5) multiplayer strategy game using deterministic lockstep for the game model, but lag can really cause inconvenience. To clarify, units don't move in real time, but the UI needs to update with player decisions, like offering trades.

StarCraft 2 uses this model PLUS some client prediction to make things feel much more responsive. How does it do this? Is there a coding pattern?

My game is currently structured with MVC. Should I be adding a ViewModel object in between the view and model so the user interface can update immediately? The major disadvantage is I would have to write quite a bit more code to create a passthrough layer for every API...

One crazy idea would be to duplicate the entire Model (call it FakeModel) and have client changes trigger immediately within it, and have it update to respect Model every so often. Unfortunately updating the whole thing could introduce it's own performance issues.

New contributor
Leon Frickenschmidt is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$
4
  • \$\begingroup\$ Using asyncronous operations with callbacks is one way to reduce lag in "networks" (P2P) if you're only making syncronous calls now. \$\endgroup\$ Commented Sep 3 at 17:03
  • \$\begingroup\$ It's not a matter of synchronous calls, it's that the user operations do not modify the model until we have received all operations from all players for a given ticket. \$\endgroup\$ Commented Sep 3 at 19:04
  • \$\begingroup\$ Its not clear from your question what synchronization model you are using, i.e. is it "Round Based" meaning all players submit actions then the actions are evaluated in a batch before the next round. "Turn Based" meaning one player takes actions, then the next player goes. Or "Real Time" meaning there is a race condition where the player clicking first/quicker has an advantage? \$\endgroup\$
    – DavidT
    Commented Sep 3 at 22:25
  • \$\begingroup\$ I'm thinking of actually including "lag" in my game. I do a lot of "predicting" (travel; fighting strength; weak/strong pts; etc.); so I know what's going to happen (more or less). On top of that, there's a chain of command. Orders in the field get executed no faster than "orders are expected to arrive". The "animations" are fire and forget; collisions, etc. are handled by "monitors" that "watch" and intercede when required. Even a "halt" command, in the field, would actually take a few seconds to comprehend and execute. And some "evolutions" would just not be interruptible unless overwhelmed. \$\endgroup\$ Commented yesterday

0

You must log in to answer this question.