Solving the Networked Physics Puzzle

Traditional networking techniques work well for simple linear motion, but start to break down when networking complex rigid-body physics simulations where objects can tumble, stack and interact with each other. This light-hearted and humorous tutorial takes a look at various options, techniques and pitfalls to watch out for when networking this sort of simulation, providing you with a tool-bag of new techniques and ideas you can use to network your physics based game.
I’ll be performing this talk at the Montreal International Game Summit on November 16, 2009 – 10:15AM in the Verdun Room. I’m honored to be invited to perform one of the first sessions at the conference and hope to see some of you guys there! Please come up after the talk if you would like to discuss anything at all I will be available for questions.
Plus, this will be my first time visiting Montreal so I’m very excited!
I have the demo for the talk almost ready and have been working on the slides over the last few weekends. Right now I’m trying to lock down the overall theme of the talk and the content. My goal is to provide lots of interesting information without going to deep into the specifics on any one thing. Ideally folks should leave the talk with a great outline of the whole field and some great ideas and inspiration to take home to apply to their own projects!
Here is a more detailed version of my talk plan:
I intend to start by asking the question: why is it that very few games provide meaningful interaction with networked physics objects? In other words, folks it’s 2009 – why exactly are we still running around mostly static worlds shooting other people in the face?
There are many reasons. It is difficult to light a dynamic world. Character movement and animation is difficult. But also, it seems very difficult to network a dynamic world. Why is this? Traditional networking techniques don’t work. Objects can stack and tumble and interact with each other.
In truth: It’s like a puzzle. It’s actually really simple – you just need to think in a different way.
Quick 5-10 minute recap of a game networking engine. UDP vs. TCP, how to construct packets, serialization, reliability, flow control. All of the stuff in my online book and more at a brisk pace for folks already in the field. My goal is simply to get everybody on the same page and provide some very useful, concrete information for folks in the field. Here is my network engine and how I do everything.
The plumbing is out of the way. Now, lets explore options for getting a physics simulation on one computer to be simply *viewed* on another. Two main options: 1) run the simulation on one side and present an approximation on the client side (pure client/server model), 2) run the simulation on both sides and synchronize via state replication. Compare and contrast these two approaches. Touch on time synchronization and real-time nature of protocol and why it is now this way vs. traditional networking technique.
Latency compensation. Consider the same situation: A simulation synchronized between two computers, but now client controls their own object. Recap traditional client side prediction from FPS games. Attempt to apply it to network this physics simulation. Problems: Rewind and replay cost. Simulation islands. Complexity. Authority scheme as an alternative. Dining philosophers problem. Distributed programming. Dykstra. Consistency vs. throughput trade-off. Case studies.
Live demo. P2P authority scheme. Late joins. Corrections. Reverse corrections. Challenge: Think outside the box. Maybe client/server should not be the automatic choice? How important is anti-cheat for your game? How important is meaningful interaction with a dynamic world? Which one wins? Is it possible to have both? How?
Future looking. What can you do moving forward? What can physics engine developers do to make their engines network better? What do we need before this becomes practical? What will game networking look like in 10 years? Bandwidth considerations. Real-time protocol requirements. IPv6. RSVP, Flow Routing. QoS guarantees. Network neutrality.
Summary. Bring it back to the original point about the puzzle. Conclusion. Best approaches for each situation. Call to action. Triumphant dance. Q&A.
That’s about it for now. Please be sure let me know what you think and if you are planning on attending the conference. Sound off in the comments below – thanks guys!
Debugging Multiplayer Games

It seems that every few months I read a post-mortem or I hear about a case where a team had to cut multiplayer at the last minute, because it didn’t fit into the schedule, or they couldn’t get it working, or because they want to “focus on the singleplayer experience”. This is especially true of teams that try to convert their existing singleplayer codebase to to support multiplayer.
Hell, I’ve even been in this situation myself with Mercs2, and I can tell you we only just made it by the skin of our teeth – despite having a good team, the full support of the studio and plenty of resources to help us out.
So why is it that so many teams fail to integrate multiplayer at the last minute? Why does it at first seem to be going so well, but then bog down as teams struggle to get it multiplayer to shipping quality?
In my experience it boils down to this: debugging multiplayer games is hard. Not just your ordinary hard. More like pulling your hair out, grown man reduced to tears, holy shit it’s 6AM I’ve been up all night and the E3 demo is in 4 hours and it still doesn’t work hard.
So in this article, I’m going to share my general process, techniques and tools that I use for debugging multiplayer games.
I hope these techniques will help you out debugging your multiplayer game!
Read the article in Networking for Game Programmers
The Return of the Timestep Crusader

Come with me now folks on a magical journey into the mind of abaraba – the timestep crusader.
Regular readers of this blog may remember the last time abaraba shared his brilliant ideas with us.
Now he’s back in a brand new episode!
You’ll discover incredible, fantastical things: how P2P actually uses less bandwidth than client/server and can scale to a larger number of players, how s=ut+1/2at^2 always provides exact results for numerical integration – and ultimately, how every single numerical integrator is completely and totally wrong because acceleration is always constant across the timestep.
So please, sit back – relax, and enjoy the following tasty links *:
devmaster.net
gamedev.net (1)
gamedev.net (2)
gamedev.net (3)
gafferongames.com
natscience.com
sci.physics.relativity
If you missed the original episode, you’re in luck – you can still catch it here:
devmaster.net
intel.com
nvidia.com
bautforum.com
gamedev.net
I hope you enjoyed your daily dose of stupid, if so then please vote this up on reddit. Remember, only *YOU* can expose the truth about time-stepping!
* ps. Hope you aren’t planning on doing anything else for the next 45 minutes…
UPDATE: Ruh-roh! Looks like abaraba has discovered philosophy!
Montreal International Game Summit 2009
Good news! I’ve been invited to speak at the Montreal International Game Summit 2009
I haven’t decided on a name for the talk yet, but it will focus on networked physics and combine material from my GDC 2009 tutorial, lecture and new material I’m going to develop over the next few months.
The basic overview of the talk is something like this:
- How the internet works and why we should use UDP
- Bandwidth considerations, packet structure, 64kbit/sec
- Describe basic algorithm for synchronization: push/pull/serialize with visual smoothing
- Synchronize one server controlled cube, client is just a viewer of simulation
- Synchronize two player controlled cubes, client and server cube.
- Effects of latency, client side prediction
- High simulation cost for rewind and replay, client side prediction breaks down in a dynamic world
- Dynamic world synchronization: options – client side prediction, no prediction, styrofoam, authority scheme
- Fiedler’s Cubes demo showing authority scheme to avoid high cost
- Corrections, reverse corrections
- Compression techniques
- Cool demo to go out
- Extended Q&A
The idea is to pretty much combine all the talks I’ve done so far on networked physics and present the information in a clear, simple manner – anybody who comes to this talk will leave with all the knowledge they need to network a physics simulation.
And of course, I get to spend a weekend in Montreal with my sweetheart about 2 months after we get married
So you see, it’s win-win folks
Aussie Aussie Aussie – OI OI OI!

Incredible. Just Incredible! Heads are screwed on right down under. After years of bungling they’ve made the right call. Just perfect!
Kevin Rudd has announced that the NBN tender process has been terminated, and that the government will go it alone on a new $43 billion broadband network.
The new wholesale-only network will connect 90% of homes with fibre to the home and will offer 100Mbit/s, with “next-generation” wireless and “third-generation” satellites to cover the remaining population. The network will be “open access” so retail ISPs can build their own products to sell to businesses and consumers.
If they keep this up, I might just start getting a bit homesick!
source: whirlpool.net.au
Almost There

If it before Friday 9AM, please please come to my talk Drop-In COOP for Open World Games in West Hall, Room 2014.
If it is after, then thankyou, good afternoon, good evening and goodnight.
If you would like to play the demo of Fiedler’s Cubes – please call me on 310-***-****, or email gaffer@gaffer.org
I’ll be in San Francisco all day today and all weekend after the conference
Wish me luck!
One Down, One To Go!

The tutorial went pretty well, I barely made the demo in time and had a few minor logistical issues, but the audience seemed to enjoy my little jokes and self-effacing australian humor so all seems to be forgiven.
I’ll say just one thing about this talk and then that’s it.
This is the first time I’ve ever spoken in public and not been deeply ashamed of my performance afterwards.
Not saying it was great. I didn’t hit it out of the park. But I did what I needed to do, I was entirely myself up on stage and I formed just a tiny small spark of connection with the audience. And by that metric, for a mere programmer who really doesn’t know what he’s doing, I think I did OK.
If you are looking for the slides they are here.
If you are looking for more information about game networking and networked physics go here.
Networking for Physics Programmers

Here are the slides for my tutorial tomorrow
The goal of the tutorial is to show people the basic ideas of how to network a physics simulation
The key points are:
- Use UDP, not TCP
- Aim for 64kbit/sec – That’s 256 byte packets, 30 times per-second **
- Handle out of order packets with a sequence number
- Send input and physics state in your packet
- Snap the physics state and extrapolate
- Run the simulation on both sides, and use the input to improve extrapolation
- Use visual smoothing to hide errors
Of course, there is a lot more to it but I hope this serves as a good starting point if you want to get into networked physics
Cheers!
** actually, that’s a little bit over 64kbit/sec, especially when you include IPsec header for consoles and UDP packet header, it’s just such a nice number for folks to remember, I couldn’t resist a little white lie
Why you really should come to my GDC talk
Two words: demo talk.
My entire talk is based around an interactive demo. It’s a demo talk. There are no slides. I have 45 minutes of material inside this interactive demo to show you guys and it’s all good stuff.
I just finished the demo today. Here’s a screenshot:

Now a bit of info on what info I’m actually presenting…
Open world games are very difficult to network. I learned this lesson the hard way on Mercs2. The key problem is that open world games have really high CPU, memory and streaming costs, so if you try networking these games using client/server you end up with two, three or four times the CPU, memory and streaming cost on the server player’s machine.
It gets worse. If players are free to go where they like then streaming performance degrades at a rate worse than linear, because you have to do lots of additional seeks when players are in different areas of the map.
All of this adds up to a gigantic pain in the ass. The sort of problem that makes grown programmers cry. And I did. You see there is really no way out other than reducing quality and tethering the players together *OR* offloading all the work to a dedicated server.
And a dedicated server gets expensive. So for Mercs2 we basically threw our hands up, reduced the hibernation distance by 50% when the second player joined the game (notice the extra pop-in during Mercs2 COOP? this is why…), and tethered the players together within 500m.
Yes we may have shipped the game with COOP, but only just.
After I shipped Mercs2 I had a hunch. What if there was some way to distribute CPU, memory and streaming cost across each player in the game? I wasn’t 100% sure, but I suspected it may be possible if I used peer-to-peer instead of client/server.
This way I could avoid paying for a dedicated server and I wouldn’t have to reduce quality or tether the players together. Overall the quality of the game would be significantly better in COOP.
So after Mercs2 shipped, I quit my job at Pandemic and started working on a demo…
If you come to my talk you get to see this demo.
In fact, everything I tell you in my talk, I’ve already coded and can show you working right in front of your eyes. I’ll even compile the fucking code live during the talk as I flip #defines to go from one part of the demo to the next.
I’ll show you how to keep a physically simulated world of one million objects in sync using peer-to-peer. How to avoid feedback, how to use an authority scheme to eliminate latency. And finally, how to support late joins so players can join and leave at any time. In summary, how to keep one million physically simulated cubes in sync using peer-to-peer. Even cubes that were pushed around before the player joined the game.
If you want to learn how do all of this then you really should come to my GDC talk!
GDC2009: Officially Shitting Bricks RIGHT NOW

Checked the calendar today, I fly out to GDC this sunday, for some reason I thought I had a week more than I did. Oh man.
Well I have my final talk layout done, and the demo is nearly finished – but I’m still scared shitless. Why?
I guess it’s always difficult to talk in front of an audience of 500 people, no matter how hard you prepare… there is always more you feel you can do. Oh and even better, my talk is 9AM friday, which means I’m get to stay in this awesome scared shitless state ALL WEEK LONG, meaning I’ll spend most of my time in sanfran practicing and preparing my talk in my hotel room. Argh.
Oh, and that previous post I gave about how to prepare a talk for GDC?
Forget everything I said and buy this book.
