A robust Java-based chess engine that adheres to standard chess rules, enabling two players to engage in a full chess game.
- Comprehensive implementation of standard chess rules.
- Calculation of legal moves for each chess piece.
- Detection of check, checkmate, and stalemate conditions.
- Support for castling.
- Extensible architecture for future enhancements.
This project employs several design patterns and OOP concepts, including:
- Builder Pattern: Used for creating complex objects like the chessboard and pieces.
- Factory Pattern: Creates pieces based on their type, promoting loose coupling.
- Strategy Pattern: Implements different movement strategies for various pieces.
- Factory Pattern: Used to create instances of pieces based on game state.
- Strategy Pattern: Employed in the movement calculation of pieces, allowing for interchangeable algorithms.
- Observer Pattern: Facilitates the notification of game state changes, such as check and checkmate conditions.
Package | Description |
---|---|
board |
Manages the chessboard and square placements. |
logic |
Contains the logic for moves and game rules. |
pieces |
Defines chess pieces and their movement rules. |
player |
Manages players and game states. |
- Square: Represents a square on the chessboard.
- Piece: Base class for all chess pieces.
- Player: Manages player actions and game state.
- Board: Represents the chessboard and the current game state.
- Moves: Encapsulates the movement logic for pieces.
Below are some visuals that showcase the chess engine in action:
An example of the chessboard state during gameplay.
Illustration of the move flow and game progression.
To run the chess engine:
- Clone the repository:
git clone https://github.com/Mahmoud-Khawaja/Chess-Engine
- Navigate to the project directory:
cd Chess-Engine
- Compile the project:
javac src/com/chess/engine/*.java
- Run the application:
java com.chess.engine.Main