How do Multiplayer Games Really Work?
Image by Sherif Salama on Flickr
Synchronizing games with players from all around the world is no easy task.
If you’re an avid gamer, there’s a good chance you’ve played an online game before. These games connect you with players all around the world in one game, so you can play with (or against!) one another. Have you ever wondered how they work? What’s going on in the background that allows your game to see the inputs of a player halfway around the globe from you?
In order for multiplayer games to fully work, there needs to be a ‘central hub’ which every player’s game reports to and receives reports from. Sometimes a game may select a specific player to be the host of the game; this is called a ‘peer-to-peer’ service. Most of the time, however, the developers of the game will provide a central server which all players connect to.
The server is where all the action takes place. You can imagine the game being played inside the server itself, if it helps! When you take an action in the game, it sends a message to the server saying what you did, and the server tells your game what happens next. As such, the main game isn’t happening on your PC; it’s happening on the server, and your game is simply a window through which you can watch and interact with the game.
Let’s look at an example. Let’s say you’re playing an online fantasy game and you cast a fireball at a zombie. Your game has to tell the server ‘my player has decided to throw a fireball at a zombie’. The server listens to this, plays it out in the game that it’s running, then sends back a message saying ‘you managed to defeat the zombie’. Your game hears this and displays the zombie’s defeat on your side.
Of course, the amount of communication between your game and the server varies depending on the kind of game being played. If you’re playing chess with someone online, then the game lets the server know where you moved your piece, and the server lets you know where your opponent moved theirs.
When you look at Fortnite, however, there’s a lot more data to tell everyone; custom clothes and animations, the weapon each player is holding, where they’re looking, what they’ve built, and whether or not they’re on the move, to name but a few. This takes a lot of work to provide a smooth game experience!
As you can see, there’s a lot of back-and-forth between your game and the server. Your game is telling the server what you’re doing, and the server is telling your game what’s happening in the world. This is all well and good, but problems start to arise when the communications get spotty. If the server is a long way away, it takes longer for the messages to reach the other side, which causes the game to feel ‘laggy’. If you ever see a server with a ‘ping’ number, this number is the amount of milliseconds it takes to talk to the server. The lower the number, the less lag there is!
Servers also have to be vigilant to uphold the game’s rules. If the server simply accepted any message from a player, then a mischievous hacker can tell the server ridiculous things like ‘my character is always full health’, or ‘my character defeats everyone on the server’. To stop this, servers need to match up what the players are saying with the game’s rules. If they spot someone trying to cheat, they can disconnect them to stop them from ruining other’s fun!
A lot of work goes into making these client-server connections run smoothly so that players can enjoy their game without issues. The next time you’re playing an online game, try to think about that.
Learn More
About Game Servers
https://en.wikipedia.org/wiki/Game_server
Client-Server Networks vs Peer-to-Peer Networks
What Gamers Need To Know About Network Synchronization In Games
https://www.makeuseof.com/tag/gamers-network-synchronization-games/
Also In The February 2019 Issue

The craft world and the tech world collide in this fun, hands-on activity.

A simple coding activity to create triangles in all shapes and sizes.

Five ideas to create that extra special gift for Valentine’s Day.

For twenty three years, since 1996, cars have used computers to control different parts of the car.

Celebrate Lunar New Year with your own custom-built lantern, complete with LEDs and micro:bit!

Synchronizing games with players from all around the world is no easy task.

A simple thought experiment sheds light on the dangers of AI. Can we stop the earth being buried in paperclips?

What do students really learn from robotics class? And how can we make it better?

Create a dynamic optical illusion in SketchUp.

Learn how rockets may soon be able to refuel in 0G. Next stop: Mars!

‘Files’ may be easy concepts for humans, but not for computers. What’s going on inside your operating system?

Two ways to play Minecraft with an overarching storyline. Experience the game like never before!

Helping kids fall in love with coding through Minecraft mods and Raspberry Pis.

Learn why this powerful, 40-year old language is still popular today.

A better, smoother way to direct your theatrical masterpiece.

Explore the past of cellular phone technology, and take a peek into its future.

How hackers can steal the messages you send over the internet, and how to tell if your communications are secure.

Add multimedia & more to your fantasy computer game to make it cooler than ever.

It’s not as simple as it seems. Can you solve this classic programming problem?

Ever wondered what happens when you connect to a website? Time to dive into the secrets of networking!

Links from the bottom of all the February 2019 articles, collected in one place for you to print, share, or bookmark.

Interesting stories about science and technology for February 2019.