TicTacToe on the command lineλ︎
Tic-tac-toe is a paper-and-pencil game for two players, X and O, who take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row wins the game
The code for this section is published on GitHub at: practicalli/tictactoe-cli
A TicTacToe game that you run on the command line. The game takes input from a human player and the program is the second player.
Output from the game appears in the REPL
Current board:
1 | 2 | 3
---------
4 | 5 | 6
---------
7 | 8 | 9
X: Select your move (press a number between 1 and 9 then press enter)
Current board:
X | 2 | 3
---------
4 | 5 | 6
---------
7 | 8 | 9
O: Select your move (press a number between 1 and 9 then press enter)
Current board:
X | O | 3
---------
4 | 5 | 6
---------
7 | 8 | 9
X: Select your move (press a number between 1 and 9 then press enter)
Current board:
X | O | X
---------
4 | 5 | 6
---------
7 | 8 | 9
O: Select your move (press a number between 1 and 9 then press enter)
Current board:
X | O | X
---------
O | 5 | 6
---------
7 | 8 | 9
X: Select your move (press a number between 1 and 9 then press enter)
Current board:
X | O | X
---------
O | X | 6
---------
7 | 8 | 9
O: Select your move (press a number between 1 and 9 then press enter)
Current board:
X | O | X
---------
O | X | O
---------
7 | 8 | 9
X: Select your move (press a number between 1 and 9 then press enter)
Current board:
X | O | X
---------
O | X | O
---------
X | 8 | 9
Player X wins!