This is a Java-based implementation of the classic Connect Four game, with support for both human and AI players. The game uses the Minimax Monte Carlo Tree Search (MCTS) algorithm to control the AI opponent, making it challenging for players.
- Two-player mode: Play against another person.
- AI mode: Challenge the AI, which uses MCTS for decision-making.
- Graphical user interface (GUI): Visualize the game board and moves.
- Winner detection: Automatically identifies the winner or detects a draw.
- Legal move checking: Ensures moves are made within the rules.
- MVC architecture: Organized code structure following Model-View-Controller design pattern.
-
AiPlayer.java
- Represents the AI player using MCTS.
- Implements the logic to decide the best column to place the piece.
- Checks for legal moves and updates the game state accordingly.
-
Board.java
- Handles the game board's state and operations.
- Contains methods for checking the legality of moves, updating the board, and detecting winners.
-
HumanPlayer.java
- Represents a human player in the game.
-
CreatePlayerController.java
- Manages the player creation and selection of human vs. AI mode.
-
Launcher.java
- Entry point for launching the application.
-
Run the Application
- Use an IDE like IntelliJ or Eclipse to run the
Launcher.java
file.
- Use an IDE like IntelliJ or Eclipse to run the
-
Select Mode
- Choose to play against another player or the AI.
-
Make Moves
- Players take turns dropping pieces in one of the columns.
- The first player to connect four pieces vertically, horizontally, or diagonally wins.
-
Game End
- If no more legal moves are possible and no winner is found, the game ends in a draw.
-
Prerequisites
- Java Development Kit (JDK) 8 or above.
- An IDE or command-line tools for Java development.
-
Steps
- Clone the repository.
- Open the project in your favorite Java IDE.
- Build the project to ensure all dependencies are met.
- Add difficulty levels for the AI.
- Implement online multiplayer mode.
- Enhance the UI with animations.
This project is licensed under the MIT License. See the LICENSE
file for details.