• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
lyleunderwood

2D Networked Physics Simulation

5 posts in this topic

I've put together a simple simulation of a chess board with 2D physics. Really simple, just top-down colliding squares. Right now all of the simulation is on the server. This actually works surprisingly well with little chop, but of course there is significant latency. I want to also run the simulation on each client, but the more I think about it the more complicated this gets.

1. The position of each piece needs to eventually end up synced.
2. If a piece is being moved by a player, it can collide with a piece, which can collide with another piece which can collide with a fourth piece which is being moved by another player.

One common solution is to only send manipulation events to the server. Get the changes made to a piece by direct interaction from the player and send positional information about it. The problem is that if I let the server just apply those changes then the likelihood that other pieces which were collided during the course of the manipulated pieces movement would closely sync with the client simulation is very low. This would break #1 above.

So let's say I can get a list of all "awake" bodies. In this case that would be any pieces that are being affected directly or indirectly from input by the player. I would then send updates for each of those bodies to the server. The problem with this arises when two players are both indirectly affecting the same piece, as in #2 above. It's possible to receive two distinctly different updates for one piece. Maybe I could average the updates together in some way? But this would lose accuracy and I feel like there would be a lot of fighting between the client and server simulations.

The ideal is to have client prediction and have a configurable small amount of latency. I just can't see how it could be accomplished in this case. Is anybody else working on this? Suggestions? Is this impossible to do well?

Thanks.
0

Share this post


Link to post
Share on other sites
Its very, very hard to get right.

Some tips:

* use a fixed time-step on client and server
* send player inputs and correct for latency - keys must be down for the *exact* number of time-steps on both client and server

The goal is to try and get exactly the same results on client + server given the same inputs. You'll probably need to hash the state of the client and compare that against the hashed state of the server to detect desyncroisation issues.

Cheers, Paul.
0

Share this post


Link to post
Share on other sites
Thanks. Is detecting desync ever accomplished using some kind of [url="http://en.wikipedia.org/wiki/Locality-sensitive_hashing"]locality-sensitive hashing[/url]? My concern is that if I'm using a physics engine like box2d then there's no guarantee that the two simulations will have strongly similar results even given the exact same beginning state and inputs. The more I think about this problem the more incredibly complicated it becomes.

Also, what the hell happened to gamedev.net? :o
0

Share this post


Link to post
Share on other sites
Look up client prediction algorithms (Gaffer Networked Physics).

The aim is to remove the latency you would get with a fully authoritative server.

i.e. client sends inputs to server, server processes inputs, run physics, returns the result back to the client. That means a round trip latency for everything the client does. In some cases that's acceptable. In many cases, it's not.

So there is a predcition / correction algorithm running between the server and clients that allows the clients to affect their view of the world in real time, while the server verifies client calculations and applies corrections for unforseen events (i.e. when two players are interacting with each other, which cannot be accurately predicted by any of them).

EDIT : That's the 5th time I've answered to that question in a month. :) Seems to come up quite a bit lately. Edited by papalazaru
0

Share this post


Link to post
Share on other sites
[quote name='WhatWhereAmI' timestamp='1346226248' post='4974345']
Thanks. Is detecting desync ever accomplished using some kind of [url="http://en.wikipedia.org/wiki/Locality-sensitive_hashing"]locality-sensitive hashing[/url]? My concern is that if I'm using a physics engine like box2d then there's no guarantee that the two simulations will have strongly similar results even given the exact same beginning state and inputs. The more I think about this problem the more incredibly complicated it becomes.

Also, what the hell happened to gamedev.net? [img]http://public.gamedev.net//public/style_emoticons/default/ohmy.png[/img]
[/quote]

Yes, this problem is hideous. You may have to author your own engine to get the guarantees you need.about the determinism.

Alternatively you can use a non deterministic engine and send correction vectors along with the keyboard inputs.
0

Share this post


Link to post
Share on other sites
[quote name='papalazaru' timestamp='1346229895' post='4974357']
Look up client prediction algorithms (Gaffer Networked Physics).

The aim is to remove the latency you would get with a fully authoritative server.

i.e. client sends inputs to server, server processes inputs, run physics, returns the result back to the client. That means a round trip latency for everything the client does. In some cases that's acceptable. In many cases, it's not.

So there is a predcition / correction algorithm running between the server and clients that allows the clients to affect their view of the world in real time, while the server verifies client calculations and applies corrections for unforseen events (i.e. when two players are interacting with each other, which cannot be accurately predicted by any of them).

EDIT : That's the 5th time I've answered to that question in a month. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Seems to come up quite a bit lately.
[/quote]

I think this prediction stuff is meant for games with a small amount of physical interaction between players, like the typical first person shooter. Additionally, in first person shooters even very small latencies degrade the gameplay so it is a good idea to integrate something like this.

I do not really know the intended gameplay, but e.g., in the lock step approach used in many RTS games, they usually just live with the latency and try to hide it somehow (acknowledgement animations etc).
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0