https://github.com/imwrdo/tic-tac-toe-java
Java implementation of tic-tac-toe game
https://github.com/imwrdo/tic-tac-toe-java
java java-core java-games
Last synced: 4 months ago
JSON representation
Java implementation of tic-tac-toe game
- Host: GitHub
- URL: https://github.com/imwrdo/tic-tac-toe-java
- Owner: imwrdo
- Created: 2025-02-17T07:18:29.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-03-01T12:24:16.000Z (10 months ago)
- Last Synced: 2025-06-02T07:02:50.461Z (7 months ago)
- Topics: java, java-core, java-games
- Language: Java
- Homepage:
- Size: 41 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tic-Tac-Toe in Java
A command-line implementation of the classic Tic-Tac-Toe game written in Java.
## Features
- Two game modes:
- Human vs Human
- Human vs Computer
- Simple command-line interface
- Computer player with strategic moves
- Input validation
- Interactive game board display
## Requirements
- Java 23 or higher
## How to Play
1. Start the game and choose a game mode:
- 1 for Human vs Human
- 2 for Human vs Computer
- 3 to Exit
2. The board is numbered from 1 to 9:
```
1 | 2 | 3
------------
4 | 5 | 6
------------
7 | 8 | 9
```
3. Players take turns entering a number (1-9) to place their mark (X or O)
4. First player to get three in a row (horizontally, vertically, or diagonally) wins!
## Project Structure
```
src
└── org.example
├── enums
│ └── Character.java - Enum representing the characters used in the game
├── logic
│ ├── core
│ │ ├── Game.java - Initializes a new game
│ │ ├── GameProcessLogicHandler.java - Handles the game loop logic
│ │ └── GameSession.java - Starts the game session by setting up players, and starting the game loop.
│ ├── gamemode
│ │ ├── HumanVsComputerMode.java - Implements the Human vs. Computer game mode.
│ │ └── HumanVsHumanMode.java - Implements the Human vs. Human game mode
│ └── menu
│ └── GameMenu.java - Manages the main menu and game mode selection
├── players
│ ├── types
│ │ ├── Player.java - Represents a Human player
│ │ └── ComputerPlayer.java - Represents a Computer player
│ └── creator
│ └── PlayerCreator.java - Handles the creation of a Player
└── Main.java - You know what it is
```
## Technical Details
- Built with Java 23
- Implements basic AI strategy for computer moves
- Object-oriented design with clear separation of concerns