Skip to content

Three in a Row

Spectrum · BASIC

Build an opponent and discover what its rules miss

11 units

Start with Draw nine squares Browse lessons
Three in a Row course capture
Three in a Row · Spectrum

Take a square, watch O’s reply and see why it chose that move. Three matching marks in a row, column or diagonal win. A full board without a winner draws.

A Three in a Row position where O has blocked the bottom row but X can still win in the left column.
A reason can be correct without making the move safe. Can you find X's winning square?

Play with 1–9, numbered across each row. You are X; the computer is O. S starts, R restarts or begins the next round, and Q quits. Completed rounds alternate who starts and add to a session tally. The final board stays visible so you can inspect the result.

The game runs in Sinclair BASIC on a stock 48K ZX Spectrum. It is silent and has no time limit. Its opponent takes an immediate win, blocks an immediate threat, then prefers the centre, corners and edges. It can be beaten: understanding that limitation is part of the game.

Build the decision

Eleven lessons use nine runnable programs. Begin with a numbered board, place crosses and add alternating players. A table of eight winning lines supplies the result checker. Then give O to the computer, improve its choices and expose the rule behind each one.

A worked fork shows why looking one move ahead can fail. Finish with opening instructions, alternating starters, a tally and a self-starting tape, then make the board easier to read by keeping each colour change to the shape that uses it. Arrays, loops and subroutines are explained where they matter; no assembly or earlier game is required. Meet BASIC provides a slower introduction to entering and running programs.