Quest2GameRead the game. Change the rules.

Lesson · 6 min Stretch

How a Machine Looks Ahead

In one line Minimax search backs up scores from the end of a tree, so its choice can be no better than the scores it starts from.

A machine looks ahead by a method called minimax search. It is working backward done by a machine: build the tree of moves, give each end position a score, and carry the scores back up to the present, assuming each side picks its best. Earlier in the course, Working Backward did the same by hand on small trees.

Take the tree shown, scored for the machine. If it grabs a pawn, the opponent can trap its queen, a loss of 6, or defend quietly, a gain of 8. If it develops a knight, the replies score 2 or 3. If it pushes the centre pawn, they score a loss of 1 or a gain of 5. The opponent will choose whatever is worst for the machine, so the three moves are worth a loss of 6, a gain of 2 and a loss of 1. The machine develops the knight. A greedy program chasing the best single score, the 8, would walk into the trap.

The rule rests on John von Neumann's minimax idea of 1928: when one side's gain is the other's loss, plan for the opponent's best reply, as Von Neumann's Minimax explained. In a real game the tree is far too big to reach the end, so the machine stops at some depth and guesses the value of the positions there with a scoring rule.

Here is the weak point. The backing up is exact, but it carries up whatever the scoring rule says. If the rule rates a pawn too highly, or misses a king in danger, a perfect search steers confidently towards bad positions. And a loss waiting one move past the search's depth stays invisible. A search is only as good as its guesses, which is why the next lesson asks how a machine could learn better ones.

  • The machine chooses
    • Grab a pawn
      • The opponent chooses
        • Trap the queen (-6, 6)
        • Defend quietly (8, -8)
    • Develop a knight
      • The opponent chooses
        • Attack the knight (2, -2)
        • Castle (3, -3)
    • Push the centre pawn
      • The opponent chooses
        • Swap pawns (-1, 1)
        • Retreat (5, -5)
Payoffs at the ends: The machine, then The opponent.
Go deeper

Programs soon found a short cut, called alpha-beta pruning. Suppose the machine has already worked out that developing the knight is worth 2. Turning to the pawn grab, it finds that one reply traps the queen, a loss of 6. It need not look at the other reply: the opponent can already hold this move below 2, so it will not be chosen. On big trees such cuts let a program search much deeper in the same time, and they never change the move it picks.

The netball plan in Rotorua

Illustration: The netball plan in Rotorua

Tahu coaches the netball team at a secondary school in the lakeside town of Rotorua. Before Saturday's final she has three set plays for the opening centre pass, and she knows the other coach will choose a defence once she sees the formation. Her assistant wants the long pass to the corner, which scored brilliantly twice last month.

Tahu draws it as a tree on the whiteboard. Against a loose defence the long pass is the best play they have, but against a tight one it is intercepted most of the time. The short pass never scores brilliantly, but against either defence it keeps the ball. "She will pick the defence that hurts us most," Tahu says, "so judge each play by that." She chooses the short pass, and tells the players that her guesses about each defence matter as much as the plan.

Try this today Before your next move in a game, check each option's worst reply, not its best, and see whether your choice changes.

Question 1 of 2

A program in Seoul has two moves to choose from. After the first, the opponent's replies leave the program 4 or 7. After the second, they leave it 10 or a loss of 3.

Which move does minimax choose, and on what grounds?

Question 2 of 2

A draughts program written by students in Nairobi searches perfectly six moves deep, but its scoring rule counts a crowned piece as worth less than an ordinary one.

What will such a program tend to do?

Cite or share this lesson

A plain reference you can paste into notes or an essay:

Quest2Game. “How a Machine Looks Ahead.” https://quest2game.com/learn/lesson/how-a-machine-looks-ahead. Accessed 30 November 2026.

Sources
  • Minimax — The minimax rule in decision-making and game theory, and its use in game-playing programs.
  • Alpha-beta pruning — The short cut that lets a minimax search skip branches that cannot change its choice.
  • John von Neumann — The mathematician who proved the minimax theorem in 1928.