← CS Unplugged

CS Unplugged activity

The Paper That Never Loses

About 30 minutesPair, or solo playing both sidesPencil, and a partner if you have one

A computer program is a list of steps followed exactly, with no thinking involved. Below is one for tic-tac-toe, in plain English instead of code: follow it in Part 1, then write your own in Part 2.

Part 1: follow the program

  1. Find a partner. No partner? Play both sides yourself, one hand for each player.
  2. Game 1: you are the Paper, the computer. Follow only the program below, no judgment calls. Your partner is the Human: they play their best move.
  3. The Paper always goes first and always plays X.
  4. Game 2: swap roles. Now your partner is the Paper and you’re the Human.

What’s a corner? The four corner squares are corners, the middle one is the center, the rest are sides. Opposite corners are diagonal, like top-left and bottom-right.

A quick look before you start

Here’s what “following the program” looks like:

Move 1, then Human plays a side

XO

Move 2

XO
X

The Paper’s program

  • Move 1. Play any corner.
  • Move 2. If the Human didn't play the corner opposite Move 1, play there now. Otherwise, play any other corner.
  • Moves 3 and 4. Same rule both times: if two of your X's share a line with the third square empty, play there and win. If not, but two O's do, play there to block. Otherwise, take a corner.
  • Move 5. Play the one square left.

Game 1: you're the Paper

Game 2: swap, you're the Human

Check yourself. The Paper should never lose, only win or draw. If it loses, someone skipped a step: find where.

Part 2: be the programmer

Now the Paper goes second and plays O. You write the rules this time.

  1. Fill in your rules below, Move 1 to 4. Hint: after a corner, take the center.
  2. Test it: your partner plays X against your program below. If it loses, find and fix the rule that failed, then try again. That’s debugging.
1
2
3
4

Adapted from Teaching London Computing: Inspiring Unplugged Classroom Activities, by Paul Curzon, Queen Mary University of London (teachinglondoncomputing.org). Licensed under CC BY-NC-SA.