Wirebook

Wirebook › Lesson 13 of 18

How does a game know you really won?

About 6 minutes · hands-on · nothing you type leaves your browser unless a button says so

When you win a game on your own tablet, the game itself is the referee: it watched every move, so it knows. But an online high-score table lives on the game maker's server, far away, and all it ever gets is a short message from your tablet saying "I scored 12". So what stops someone sending "I scored a million"? Play a quick game, then try to fool the server.

Fool the high-score server

Catch the stars for 10 seconds. Your tablet then writes the message it would send to the server. Before you press Send you can change it, just as a cheater could. Then switch on the server's checks one by one and see which cheats still get through. The server here is pretend and lives in this page, so nobody else's score is spoiled.

High-score table

    Try a cheat:
    The server's checks (0 of 3 on)

    Press Start to play, or jump straight to a cheat.

    Who is the referee?

    In a game you play on your own, your tablet is the referee. It knows where the stars were and which ones you touched, and it decides when you've won. Nobody else needs convincing. That's also why people can use cheat codes or edit save files in single-player games: the tablet belongs to them, and the only person "cheated" is themselves.

    An online leaderboard is different. The server can't see your screen. All it receives is a message from your device, the client, a bit like the one in the box above. And here's the catch: anything on your device, including that message, can be changed by whoever is holding the device.

    The golden rule of online games: never trust the client. Programmers say it a lot. It means the server treats every message as a claim, not a fact, and checks it before believing it.

    Three ways a server can check

    1. Is it even possible? The simplest check. If only 14 stars ever appear, a score of 999,999 is a lie. Real games check things like "nobody can finish this level in 2 seconds" or "you can't have more coins than the game ever gave out". It catches the lazy cheats, but not a believable score.

    2. Show your working. Like a maths teacher, the server asks for the moves, not just the answer. It knows where every star appeared (it gave the game the same starting number, the seed, so it can work out the same pattern), replays your taps and counts for itself. If its count doesn't match your score, somebody changed the score. Racing games do this with "ghost" replays of record laps.

    3. Too perfect? A cheater can write fake moves that add up correctly. But people are slow and wobbly: most of us need around a quarter of a second to react, and never the same time twice. Taps that arrive 90 milliseconds after every single star, every time, look like a robot. This is how many games spot bots: programs that play for you.

    A sneaky trap some games plant. A few online games leave a fake prize sitting in plain sight — a golden star only a too-perfect bot would always grab, while a person might miss it. When a player (or bot) takes the bait, the server knows. It's another way of asking "too perfect?" without only looking at reaction times.
    So why did the wobbly bot get through? Because every check above only looks at one message, and a careful cheat can make one message look human. That's why big online games go further. In many of them the server is the referee: your device only says "I pressed jump", and the server decides where everyone really is, so you can't simply give yourself coins or walk through walls. Bots with perfect aim can still press buttons, so games also look for patterns over many games (nobody wins every round with a perfect score), let players report cheaters, and sometimes run anti-cheat programs on your device too. It's a race that never quite ends.

    Couldn't the game just put a secret code on the message?

    Some games do: the app adds a secret stamp to each message, worked out with a hidden key, like the fingerprints in the secret-codes lesson. That stops anyone changing a message on its way across the internet (the padlock in your browser already does that too). But the key has to be inside the game app, and the app is on the cheater's device. A determined cheater can dig it out. A secret you hand to everybody isn't much of a secret.

    Try cheating here, not there. In real online games, cheating breaks the rules, spoils the game for everyone else and can get an account banned. This pretend server is the place to experiment.

    Words from this lesson

    Earn your stamp

    Get all 3 right to collect the High scores & cheats stamp. Wrong answers are fine: just try again.

    1. For an online high-score table, what does the game's server actually get from you?

    2. Someone sends a score of 1,000,000 in a game where only 14 stars ever appear. Which check catches it?

    3. Why do many big online games make the server the referee?

    Try another lesson

    1. 14How can lots of people play the same game together?7 min · interactive
    2. 15How does a website check your password without keeping it?8 min · interactive
    3. 16How can you spot a fake message?7 min · interactive