Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: synchronizing game mechanics online

  1. #1

    synchronizing game mechanics online

    I'm currently brainstorming on my Lemmings Multiplayer Online Game and solving problems in my head already.
    Now the next problem must have been encountered by other game-programmers too:

    How do you synchronize game-mechanics when some people are playing a game together?
    Let's take a lemmings-level as example. 2 players have control over their own lemmings in the same level. Now we know lemmings can change the world they are in, by building digging etc.
    I can imagine problems because of network-latency (lag) for example: Player A starts digging at frame 100, Player B starts building at the same place at frame 100, but because of lag does not yet see what player A is doing.
    How to handle these kind of problems? The Lemmings game needs a high degree of precision on timing and pixels.

  2. #2

    Re: synchronizing game mechanics online

    Yes that is quite a puzzle.

    One thought
    - what is leading server vs clients

    You say the clients are leading giving the problems you mentioned.
    Try to add a server (could be a client) and let that control the logic.
    e.g. look at quake.
    http://3das.noeska.com - create adventure games without programming

  3. #3

    Re: synchronizing game mechanics online

    No I'm not saying the clients are leading.
    I just try to think of a way in which the games are in sync. Ideally there is one game on the server, I think.
    Code:
    Look at Quake
    What do you mean?

  4. #4

    Re: synchronizing game mechanics online

    quake (3 arena) can be played online and uses one client to be a server to that other clients conect. The server keeps everything in sync. Quake is opensource so it may be of help.

    Also try to search this forum.
    http://3das.noeska.com - create adventure games without programming

  5. #5

    Re: synchronizing game mechanics online

    Hi,

    as Noeska already wrote: client/server based games normally work in the following way: The clients send the player's actions to the (single) server. While there is no response from the server, the game continues as if it was a single player game. Finally everything gets synced by the server - so in your case you would have to implement something like an "undo" if an action has been marked as invalid - or you have to ask the server for permission everytime an action is performed by the player. Most time the latency (in the internet) should be < 100ms, so this shouldn't be a real problem.

  6. #6

    Re: synchronizing game mechanics online

    Quote Originally Posted by igel457
    Most time the latency (in the internet) should be < 100ms, so this shouldn't be a real problem.
    Not very often from my experience. Latency that low can only be achieved realistically if playing with people from your own country only. In common international games (WoW, GW) i see anything between 100ms to 300ms but when i ask other players about their ping it is usually even higher.

    To topic though.. it is best to do what you can as far as possible and analyze where it goes wrong. Game is only synchronized when everything happens in same order same time. To do that something will have to wait for permission to go forward ("tick") or be stored in case of rollback. Both have their downsides; either game control seems laggy or game visuals may suddenly appear elsewhere. Personally i'd go for control tick and server that is process on its own but that is subject that i still have to test.

  7. #7

    Re: synchronizing game mechanics online

    Hmm, some good ideas here. Thanks for the answers. I dont know if I can read the code of Quake, but i'll analyze the different options.

  8. #8

    Re: synchronizing game mechanics online

    The answer to this question is a very long and tedious one. There are literally 1000's of articles on the net about this, some of the best are on Gammasutra and GD.

    Long and short of it is:
    Lat should be thought of as the time it takes for a message to be delivered and how the size of that message affects that delivery time. Make sure your message size is appropriate to your pipe and keep the sends in tight bursts. If you can get 2 or 3 messages into one packet then do so.
    Use two types of networking, UDP and TCP. Research both, and it should be obvious why and when to use each.
    Consider multiple types of message importance. Make sure you process the most important 1st and wait for the less important ones.
    Realize it won't be perfect, just get it close enough. Some of the best parts of games are due to "bugs" in the network.

    For your example about digging and building. Here is one way of achieving it:
    Client 1, send lock x,y to server
    Client 2, send lock x,y to server
    Server gets client 2 request first, locks x,y and sends ok to client 2
    Server broadcasts client 2's lock
    Server gets client 1's request, sends fail
    Client 1 gets fail back. Don't change animation.

    To achieve this, you have an interm animation. I tell him to dig and build, he "thinks" for a split second (maybe a question mark above head) while messages are sent and received. Once a "decision" is made by the server, the animation changes as appropriate.

    Hope that helps, remember your problem is only as big or small as the solutions you come up with. In this case, having interm animations makes the most sense. It also adds to the lemings feel

  9. #9

    Re: synchronizing game mechanics online

    Ok sounds good. Only thing is: the server does not really have to "play" the game, because it's not a global game (like WoW for instance). The game is played by 1 to max 10 people, so maybe (if i understood correctly) a Quake model is best:
    One of the players who is actually playing the game with a group has the function of server? All synchronization is done through this one player of the group.
    Of course the computer of the leading player is more busy than the other ones, but it seems to me that that's better than playing ALL games globally on one server.
    Again: I have no experience with online programming at all. Just brainstorming on it, for the moment...

  10. #10

    Re: synchronizing game mechanics online

    From programmer point of view it should be simplest to make server actually play the game and control it for all players. Having 1 client act as server is vulnerable to very difficult to find bugs that only certain players experience. Full server style makes all players equal. Still, you can make that server run as a thread within 1 client that creates the game.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •