Wirebook › Lesson 14 of 18
How can lots of people play the same game together?
You and your friends are in different houses, but you're all running around the same park in a game. Who decides where everyone really is? Is there a giant invisible playground somewhere? Sort of: it's a shared world kept on a server, and every move is a short message racing across the internet. Here's a little park so you can see the messages, the lag, and who gets the star when two people grab it at once.
Is there a giant invisible playground?
Yes, in a way. When lots of people play the same game from different houses, there has to be one shared world that everyone agrees on: where each player is, who has which star, whose score is what. That shared world lives on the game maker's server, a computer that keeps the park in its memory and answers messages from every tablet. Your tablet doesn't invent the truth on its own; it asks the playground and draws what it's told.
Every time you press an arrow, your tablet sends a tiny message: "Fox wants to step right." The server checks whether that move is allowed (is the square empty? is the star still there?), updates the shared park, and tells every tablet "Fox is now at square 4,2 and got the star." Friends in other houses see you move because their tablets get the same update.
Why does lag make the park feel weird?
Messages aren't instant. The time a message takes to travel is called latency, or lag. Under the sea and across cities, even at the speed of light, a round trip often takes 30 to 100 milliseconds, and on a busy Wi-Fi it can be much more. In the playground above, the lag slider is how long each message spends "in the post".
If your tablet waited for every reply before moving the fox on your screen, the game would feel sticky: you'd press right and the fox would freeze for a tenth of a second. So most games guess first. Your tablet moves the fox straight away (that's called prediction), and when the server's reply arrives it checks whether the guess matched. If it did, nothing changes. If it didn't — maybe a friend grabbed the star a moment earlier — the fox snaps back to where the server says it should be. That snap is the rubber-band feeling in online games.
Try it above with lag turned up and "Guess first" on: your tablet looks ahead, then the shared park catches up. Switch guessing off and every step waits for the post.
Who got the star?
When two players step on the same star "at the same time", their messages still arrive one after the other. The server deals with them in order: the first message that reaches it wins the star, and the second finds the square empty. From each player's house it can feel unfair ("I was clearly first!"), because each tablet saw its own move instantly. The shared park settles the argument.
Real games do this many times a second. The shared world updates on a steady beat, a tick, often 20 or 60 times a second. Between ticks the server queues moves, then applies them in order and broadcasts the new picture. Faster ticks feel snappier but cost more work; slower ticks save power and bandwidth.
Related lessons: how a game controller talks to the console (the lag before your move even leaves the house) · why the game lags when someone starts a download.