A command-line Tic-Tac-Toe game implemented in Java, featuring multiple game modes including single-player against CPU and customizable player symbols.
- Three distinct game modes: Basic, Advanced, and CPU
- Customizable player names and symbols
- Single-player mode with computer opponent
- Score tracking across multiple games
- Input validation with helpful error messages
- Clean console-based interface
- Java Development Kit (JDK) 8 or higher
To verify your Java installation:
java -version
javac -version-
Clone the repository:
git clone https://github.com/dalouc/tic-tac-toe.git cd tic-tac-toe -
Compile the source code:
cd src javac *.java
-
Run the game:
java TicTacToe
Upon launching, select a game mode by entering the corresponding number:
Select the game configuration:
Basic (0)
Advanced (1)
CPU (2)
After each game, you can choose to play again. The program tracks wins and draws across sessions.
| Mode | Description |
|---|---|
| Basic (0) | Classic two-player game with default names and symbols (X and 0) |
| Advanced (1) | Two-player game with custom names and selectable symbols |
| CPU (2) | Play against the computer or use advanced mode for two players |
When selecting CPU mode, choose between:
- 1-player (0): Play against the computer. You can set your name and symbol.
- 2-player (1): Defaults to Advanced mode with full customization for both players.
In Advanced and CPU modes, players can choose from:
X 0 A B C D E F G H I J K L M N O P Q R S T U V W Y Z + * - @ 1
Note: Once selected, symbols cannot be changed during the game session.
Positions are entered using coordinate notation:
(row,column)
Both rows and columns are numbered 1 to 3:
Col 1 Col 2 Col 3
+-------+-------+-------+
Row 1 | (1,1) | (1,2) | (1,3) |
+-------+-------+-------+
Row 2 | (2,1) | (2,2) | (2,3) |
+-------+-------+-------+
Row 3 | (3,1) | (3,2) | (3,3) |
+-------+-------+-------+
- Use parentheses:
(row,column) - No spaces allowed
- Numbers must be between 1 and 3
Examples:
| Input | Position |
|---|---|
(1,1) |
Top-left corner |
(2,2) |
Center |
(3,3) |
Bottom-right corner |
Invalid inputs will prompt you to re-enter the position.
Alfonso Cecilia Martínez and Daniel Lozano Uceda