Tic-tac-toe

The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row first is the winner.

Because of the simplicity of tic-tac-toe, it is often used as a pedagogical tool for teaching the concepts of good sportsmanship and the branch of artificial intelligence that deals with the searching of game trees.

It is straightforward to write a computer program to play tic-tac-toe perfectly or to enumerate the 765 essentially different positions (the state space complexity) or the 26,830 possible games up to rotations and reflections (the game tree complexity) on this space.

[6] It can be generalised even further by playing on an arbitrary incidence structure, where rows are lines and cells are points.

It was called terni lapilli (three pebbles at a time) and instead of having any number of pieces, each player had only three; thus, they had to move them around to empty spaces to keep playing.

[11] The first print reference to a game called "tick-tack-toe" occurred in 1884, but referred to "a children's game played on a slate, consisting of trying with the eyes shut to bring the pencil down on one of the numbers of a set, the number hit being scored".

[This quote needs a citation] "Tic-tac-toe" may also derive from "tick-tack", the name of an old version of backgammon first described in 1558.

[13][14] The computer player could play perfect games of tic-tac-toe against a human opponent.

The second player, who shall be designated "O", must respond to X's opening mark in such a way as to avoid the forced win.

Once the opening is completed, O's task is to follow the above list of priorities in order to force the draw, or else to gain a win if X makes a weak play.

Tic-tac-toe is an instance of an m,n,k-game, where two players alternate taking turns on an m×n board until one of them gets k in a row.

The game can be generalised even further by playing on an arbitrary hypergraph, where rows are hyperedges and cells are vertices.

Another variant, Qubic, is played on a 4×4×4 board; it was solved by Oren Patashnik in 1980 (the first player can force a win).

Game of Tic-tac-toe, won by X
Game of Tic-tac-toe, won by X
Incidence structure for tic-tac-toe
Optimal strategy for player X if starting in upper left. In each grid, the shaded red X denotes the optimal move, and the location of O's next move gives the next subgrid to examine. Only two sequences of moves by O (both starting with the center, top-right, left-mid) lead to a draw, with the remaining sequences leading to wins from X.
Optimal strategy for player O. Player O can only force a win or draw by playing in the center first.