CS Unplugged activity
The Paper That Never Loses
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
- Find a partner. No partner? Play both sides yourself, one hand for each player.
- 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.
- The Paper always goes first and always plays X.
- 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
| X | O | |
Move 2
| X | O | |
| 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.
- Fill in your rules below, Move 1 to 4. Hint: after a corner, take the center.
- 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 |
Version history
- Loading commit history…