MyLeoNes™

Random choices — Computing, 4–6

A computer can choose one possibility without knowing which one will come first, like picking a card from a shuffled pack.

A fair surprise

Sometimes a computer needs to choose one thing from several possibilities. It can make a random choice, so no option is picked because it came first or because the computer prefers it. Each choice has a chance, like each face of a fair die.

Why use chance

Games use chance to stop every round being exactly the same. A computer can choose a hidden treasure place, an opponent’s move or the next colour. This gives players a surprise while the rules stay the same. Chance is useful when there is no special reason to choose one option.

Choosing a colour

A game has three cards: red, blue and yellow. First, the computer gives each card a number: 1, 2 and 3. Next, it chooses one number at random. If it chooses 2, the game shows blue. The same steps can give a different colour next time.

Random is not a pattern

It is reasonable to expect red after blue if a game showed red, blue, red, blue. Humans spot patterns very quickly. But a random choice does not remember what happened before, so blue may come again. A short run can look like a pattern without being one.

Where chance appears

You meet computer-made chance in dice games, shuffled music, surprise creatures and the order of turns in a game. It can also help choose a sample in a science activity. If the choice matters, ask an adult whether the computer’s choice is truly fair.

Keep exploring

Other languages

Loading MyLeoNes™…