MyLeoNes™

Computer games have rules — Computing, 4–6

A game feels alive because it keeps checking rules: where things are, what you did and what should happen next. Under the pictures and sounds, code is keeping track of a small world.

The game keeps track of a world

A computer game has things to remember: your player’s place, the score, and whether a door is open. When you press a button, the game checks its rules and changes some of those things. The screen then shows the new situation.

Why do games need rules?

Without rules, pressing a button would have no clear result: a character might move through a wall or win for no reason. Rules give actions meaning and make the game fair enough to learn. Game makers use code to keep checking these rules much faster than a person could.

Catching three stars

Imagine a game with three stars and a player. At the start, the score is 0. You touch the first star, so the rule removes it and adds 1: the score is now 1. After touching the second and third, the score becomes 2 and then 3, and the game can say “You collected them all!”

The screen is not the whole game

It is reasonable to think the game is only the colourful picture you see. The picture is the part you can look at, while hidden rules keep track of places, scores and changes. If the picture looks wrong, the rules may still be working; if the rules are wrong, a beautiful picture can still behave strangely.

Rules outside games

The same idea appears in traffic lights, ticket machines and washing machines. Each one remembers a small situation and follows rules about what to do next. A washing machine, for example, does not spin at every moment: its program decides when to fill, wash, rinse and spin.

Keep exploring

Other languages

Loading MyLeoNes™…