Kaamkoby ICE

Tic-Tac-Toe

Take turns marking squares on a 3 by 3 grid. Three of your marks in a row, column or diagonal wins.

Wins0
Draws0
Losses0

X moves first.

Controls

Keyboard
Arrow keys move between squares and Enter marks one, or press 1 to 9 (1 is top left). N starts a new game.
Touch
Tap an empty square to put your mark there.

Your best score stays in this browser only. Nothing is sent anywhere. The game pauses when you switch tabs.

About Tic-Tac-Toe

Tic-tac-toe, also called noughts and crosses, is one of the oldest paper games there is. Two players take turns writing X and O on a grid of nine squares, and the first to get three in a line wins. Children in Nepal play it in the back of exercise books and on dusty ground with a stick. It is small enough that a computer can check every possible game, which makes it the classic first example of game search in computer science.

This version is written from scratch for Kaamko. You can play the computer on two levels or pass the phone to a friend. Your wins, draws and losses against the computer are counted in this browser only.

How to play Tic-Tac-Toe

  1. X always moves first. Choose X to start, or O to let the computer start.
  2. On your turn, tap or click an empty square to put your mark there. On a keyboard, move with the arrow keys and press Enter, or press a number key from 1 to 9 (1 is the top left square, 9 the bottom right).
  3. Three of your marks in one row, one column or one diagonal wins the game.
  4. If all nine squares fill up and nobody has three in a line, the game is a draw.

How to never lose

With correct play from both sides, every game of tic-tac-toe is a draw. The unbeatable computer plays perfectly, so the best you can do against it is a draw, and that is a fair goal. As X, the corner is the strongest start: if O answers anywhere but the centre, X can force a win. As O, always answer a corner opening by taking the centre, and answer a centre opening by taking a corner. After that, the rule is simple: win if you can, block if you must, and look for a move that makes two threats at once, called a fork. A fork wins because your opponent can only block one line.

How the computer thinks

The unbeatable level uses minimax. It tries every move, then every reply, all the way to the end of the game, and picks the move with the best guaranteed result, preferring faster wins and slower losses. There are only 255,168 possible games, so this takes no time at all. The easy level picks a random square most of the time and only sometimes plays the best move, so it leaves room for your forks.

Written from scratch by Imperial College of Engineering for Kaamko. No third-party code or art.

Last checked by Imperial College of Engineering. Played through on desktop and a 390px phone screen on this date.