A fully functional chess engine implemented in Java with a graphical user interface (GUI) to simulate a chessboard and allow players to play chess. The game supports piece movement, basic rules of chess, and utilizes a custom set of piece images for display.
This project is a Java-based chess engine designed to simulate a chess game on a virtual board. The game implements the logic for all chess pieces, including Pawns, Knights, Bishops, Rooks, Queens, and Kings, as well as the rules that govern piece movement. The engine includes a GUI that displays the board and allows players to interact with the pieces through mouse events.
The project is organized into well-structured code that separates the logic for the board, pieces, and game flow. It also includes a set of resources for the chess piece images, making it visually appealing.
- Full chessboard representation with 8x8 grid.
- All chess pieces: Pawn, Knight, Bishop, Rook, Queen, and King.
- Piece movement based on chess rules.
- Drag-and-drop functionality for piece movement.
- Basic check and checkmate conditions.
- Support for white and black pieces.
- Easy-to-use GUI for an interactive chess experience.
The project is structured as follows:
Java-ChessEngine/
├── Chess.iml # Project configuration file
├── out/ # Compiled class files
│ ├── com/
│ │ ├── main/
│ │ │ ├── Board.class
│ │ │ ├── GamePanel$1.class
│ │ │ ├── GamePanel.class
│ │ │ ├── Main.class
│ │ │ ├── Mouse.class
│ │ │ └── Type.class
│ │ └── piece/
│ │ ├── Bishop.class
│ │ ├── King.class
│ │ ├── Knight.class
│ │ ├── Pawn.class
│ │ ├── Piece.class
│ │ ├── Queen.class
│ │ └── Rook.class
├── README.md # Project documentation
├── res/ # Resource files (piece images)
│ └── piece/
│ ├── b-bishop.png
│ ├── b-king.png
│ ├── b-knight.png
│ ├── b-pawn.png
│ ├── b-queen.png
│ ├── b-rook.png
│ ├── w-bishop.png
│ ├── w-king.png
│ ├── w-knight.png
│ ├── w-pawn.png
│ ├── w-queen.png
│ └── w-rook.png
├── src/ # Source code
│ └── com/
│ ├── main/ # Main application logic
│ │ ├── Board.java # Board representation and state management
│ │ ├── GamePanel.java # GUI panel for the chessboard
│ │ ├── Main.java # Entry point for the application
│ │ ├── Mouse.java # Mouse event handling for piece movement
│ │ └── Type.java # Enum for piece types
│ └── piece/ # Chess piece logic
│ ├── Bishop.java # Bishop piece implementation
│ ├── King.java # King piece implementation
│ ├── Knight.java # Knight piece implementation
│ ├── Pawn.java # Pawn piece implementation
│ ├── Piece.java # Base class for all chess pieces
│ ├── Queen.java # Queen piece implementation
│ └── Rook.java # Rook piece implementation
└── structure.txt # File structure overview
To run the chess game, follow these steps:
-
Clone the repository:
git clone https://github.com/your-username/Java-ChessEngine.git
-
Compile the source code: If you're using an IDE like IntelliJ IDEA or Eclipse, simply open the project and build it. Alternatively, use the command line:
javac -d out/ src/com/main/*.java src/com/piece/*.java
-
Run the application: Navigate to the compiled class files directory and run the
Main.class:java com.main.Main
-
Play chess! The GUI will launch, allowing you to interact with the game.
- Java: Core programming language for implementing the chess engine.
- Swing: Used for creating the GUI components.
We welcome contributions! If you'd like to improve or extend the project, feel free to submit a pull request. Before doing so, please ensure that your code adheres to the following:
- Fork the repository.
- Create a feature branch.
- Make your changes.
- Test your changes.
- Submit a pull request.
Here are some ideas for future improvements:
- AI Opponent: Implement a basic AI using algorithms like Minimax with Alpha-Beta pruning.
- Multiplayer Support: Add online multiplayer functionality using sockets or a web-based API.
- Move History: Display a list of previous moves for both players.
- Sound Effects: Add sound effects for moves, captures, and checkmate.
- Themes: Allow users to choose different board and piece themes.
- Save/Load Game: Implement functionality to save and load game states.
- Chess Clock: Add a timer for each player to simulate real-world chess games.
This project is licensed under the MIT License - see the LICENSE file for details.
Happy coding and enjoy playing chess! ♟️