Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (595)
Games in Android Showcase (168)
games submitted by our members
Games in WIP (646)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Server-Client Synchronisation  (Read 3004 times)
0 Members and 1 Guest are viewing this topic.
Offline kevglass

« JGO Spiffy Duke »

Medals: 272
Projects: 25
Exp: 18 years

Coder, Trainee Pixel Artist, Game Reviewer

« Posted 2003-08-26 05:39:38 »

I'm currently working on a 2D space based game, persistent universe, trading, missions etc. You can see some information at

The first version I produced maintained client state locally. The client would "tell" the server what its location, velocity and rotation were and the server would broadcast this to other players in the area. This worked fine but was worrying from a security point of view. When adding asteroids and collisions I discovered the server needed to caculated the collision results and hence needed to reset the clients position and velocity. So I then had this problem of knowing which side (client or server) had the appropriate and accurate information about the players position.

Since then I've started work on the MMO version, and decided to look at the networking again. I've just implemented a version where the client maintains only its controls. The client "tells" the server if its thrust, rotating or firing. The server runs all the players updating them as appropriate and broadcasts the results to the players (including the original client). This give me a wonderful central control of the world but at high latency its going to give the player a lack of control of the ship.

I was wondering if there is a more appropriate half-way house, or if I just have to choose between the two.

Any feedback much appreciated,


Offline Conzar

Junior Devvie

There is nothing common about common sense

« Reply #1 - Posted 2003-08-26 15:37:26 »

So there are 2 views that you described:
1. Simulation all done on the server
2. Simulation all done on the clients

There are advantages and disadvantages to both schemes.  You asked if you can do some of the simulation on the server and some on the clients.  I think thats valid.  

This is one of the subjects that I am currently looking at for my Master's Thesis (I haven't nailed this down yet though).

So something to think about for the combined thing (oh yea, how you break it up is dependent on the type of game)...
Do all AI on the Server (treat AI/NPC's like human clients on client side).
Let Clients do their own movement collision detection - just update server of their location.

This can be done multiple ways
When attacking, the attacker can determine if he hit something
The attackie (is that a word) can determine if he was hit
Or the Server can determine that the attacker hit the attackii

Also note, security is an issue whether you do 1, 2, or combination of them.  The benefit of doing 1 is that since the server holds the current state, then if the client does something invalid then only that client's simulation is invalid, this doesn't effect anyone else.  

So to attempt to answere your question, I really don't know.  I hope to find out...

Offline Athomas Goldberg

Junior Devvie


« Reply #2 - Posted 2003-08-26 23:50:11 »

Doing everything on the server is certainly your most secure option and the easiest way to go as far as synchronizing multiple actions between players. Doing things on the client can reduce latency, thereby increasing responsiveness, but also leaves you open to cheating.

If your game is such that you actually have the option of doing it in either place (your not CPU restricted on either side) you may want to consider running as much of the local simulation as you can on BOTH the client AND the server and then periodically reconcile the client with the server as it drifts out of sync. In this case, the server is the ultimate authority so you always assume the server is right (just as you would in the scenario where only the server is running the sim) Obviously, there are some tradeoffs to doing it this way, but there have been a number of articles on doing this adjustment gracefully, so this may be the best way for you to go. I'll poke around my bookshelf and see if I can find a couple good ones to point you to.

Athomas Goldberg
Project Lead / Wildcard
Game Technologies Group
Sun Microsystems, Inc.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

« JGO Spiffy Duke »

Medals: 272
Projects: 25
Exp: 18 years

Coder, Trainee Pixel Artist, Game Reviewer

« Reply #3 - Posted 2003-08-27 04:22:14 »

That'd be really useful.


Offline larry

Junior Devvie

.. son of jor-el, kneel before zod ...

« Reply #4 - Posted 2003-08-27 08:09:38 »

Im an expert, by no accounts on such an issue.
but Im sure you've already looked em up.

I think it depends on the type of game, the architecture you're supporting, the pace of your game, the amount of data that must be synchronised and the inherint network latency.

Im sure you can analyse your system and try hone down your data synchronisation to the bare minimum. Moreover, you can identify which data are continuous or require immediate updates (e.g. velocities) and which data doesnt (e.g. new player login). But Im sure you've done all that.

The simplest solution would be Athomas Goldberg's suggestion which would be to replicate processing on both client and server.

The only other solution I can think of is, writing some sort of rules-engine on the server which determines whether a new velocity, etc. value from a client is "legal" taking into account its previous state and states of other objects in the world.

but I suppose this amounts to the same as the 1st solution.


Offline kevglass

« JGO Spiffy Duke »

Medals: 272
Projects: 25
Exp: 18 years

Coder, Trainee Pixel Artist, Game Reviewer

« Reply #5 - Posted 2003-08-27 08:40:08 »

As you say, I've covered most of this, infact most of the static stuff (game login, player creation, trading) is done on sepearate channel (and server actually).

Running the world both on the server and the client could be useful, but can you get away with calculating collisions on the client?

I'm gonna a try a bunch of stuff out and I'll post if I find anything interesting Smiley


Offline abies

Senior Devvie

« Reply #6 - Posted 2003-08-27 11:04:56 »

If you can find a collision which can be only beneficial to client, maybe you can check for this collision in client and if it happens, have server doublecheck that. In this way, you don't have to check misses on server. No reason to hack, because false positives would be catched on server, while false negatives would be a penalty for user.

Of course, you can do this only for things which are clearly beneficial to player. In case of laser/ship, you probably should ask client which fired whenever there was a hit, not the victim Smiley

Of course, there is a question of difference of time/position between server and client.

Artur Biesiadowski
Offline Markus_Persson

JGO Wizard

Medals: 16
Projects: 19

Mojang Specifications

« Reply #7 - Posted 2003-08-27 13:31:53 »

One idea I've been thinking of is to predict local movement on the client (the ship accelerates when you press forward, and turns left when you press left and so), then sending the keypresses and keyreleases to the server with a timestamp.

The server can then run the exact same code as the client, figure out exactly where the client has moved his ship, and be sure that it's all been done "legally".

To prevent rounding errors from adding up, the client can just send it's exact position to the server at regular intervals (timestamped as well, of course), and then the server just checks if the new position is close enough to where it thinks the player is, then uses that position instead.

Play Minecraft!
Offline kevglass

« JGO Spiffy Duke »

Medals: 272
Projects: 25
Exp: 18 years

Coder, Trainee Pixel Artist, Game Reviewer

« Reply #8 - Posted 2003-08-27 13:47:24 »

Nice to see, thats exactly how my first version of astro prime worked Smiley

Was just trying other options for the new version


Offline endolf

JGO Coder

Medals: 7
Exp: 15 years

Current project release date: sometime in 3003

« Reply #9 - Posted 2003-08-28 06:36:35 »

 It's what I had pondered for my game, I wouldn't check *every* client as the plan is there will be too many to check them all Smiley, but at some point every client would get checked in a ten minute period for example, this leaves some server cpu for other things, like AI etc, without requireing a cray to run the server Smiley



Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Markus_Persson

JGO Wizard

Medals: 16
Projects: 19

Mojang Specifications

« Reply #10 - Posted 2003-08-28 06:54:16 »

To REALLY prevent cheating, you could make the testing random, and the "kick-on-cheat" delayed by a minute or so. Wink

Play Minecraft!
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Riven (22 views)
2015-07-03 11:22:16

deepthought (47 views)
2015-06-30 15:39:44

deepthought (49 views)
2015-06-30 15:39:09

deepthought (62 views)
2015-06-30 15:36:52

Za\'Anzabar (34 views)
2015-06-29 05:44:54

TritonDreyja (45 views)
2015-06-24 17:10:40

CopyableCougar4 (45 views)
2015-06-23 00:34:45

BurntPizza (50 views)
2015-06-21 20:36:46

cookiecompiler (91 views)
2015-06-11 15:42:53

cookiecompiler (54 views)
2015-06-11 15:41:14
How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!