https://github.com/shendriks/tic-tac-toe-java
A CLI implementation of Tic Tac Toe in Java using the Minimax algorithm
https://github.com/shendriks/tic-tac-toe-java
java minimax minimax-algorithm tic-tac-toe tic-tac-toe-game tictactoe
Last synced: about 1 year ago
JSON representation
A CLI implementation of Tic Tac Toe in Java using the Minimax algorithm
- Host: GitHub
- URL: https://github.com/shendriks/tic-tac-toe-java
- Owner: shendriks
- License: mit
- Created: 2025-05-05T08:50:58.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-05T14:04:12.000Z (about 1 year ago)
- Last Synced: 2025-05-05T14:48:32.189Z (about 1 year ago)
- Topics: java, minimax, minimax-algorithm, tic-tac-toe, tic-tac-toe-game, tictactoe
- Language: Java
- Homepage:
- Size: 84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tic-tac-toe
[](https://github.com/shendriks/tic-tac-toe-java/actions/workflows/gradle.yml)
A CLI implementation of Tic Tac Toe in Java using the Minimax algorithm
## How to play
This is a simple CLI application. Once started, it expects the user to enter a
command:
```text
Input command (type help for help):
```
There are three commands:
1. `help`
2. `start ` with `` being one of: `user`, `easy`, `medium`, `hard`
3. `exit`
The `help` command prints some helpful information about the commands available, while the `exit` command exits the
application. This leaves us with the `start ` command which expects the types of the two players.
### The Player Types
There are four player types:
1. `user`: a human player
2. `easy`, `medium` and `hard`: more or less "intelligent" opponents controlled by the computer
When it's a human player's turn, they are asked to enter the coordinates of their next move in form of two integers
ranging from 1 to 3 each, e.g.:
```text
Enter the coordinates [row column]: 1 1
```
By entering `1 1` an X (or an O - depending on if they're the first or second player) is placed in the upper left corner
of the board:
```text
+-------+
| X |
| |
| |
+-------+
```
### Computer controlled Opponents
* `easy` - this one just makes random moves
* `medium` - this one makes random moves, unless they can make a winning move (if they already have two in a row) or a
blocking move (if the opponent has two in a row)
* `hard` - this one uses the Minimax algorithm to make the best move possible