A feature-rich chess game implementation in Java with a graphical user interface built using Swing. This project supports both traditional chess and Chess960 (Fischer Random Chess) variants.
- Traditional Chess: Complete implementation of standard chess rules
- Chess960 Support: Fischer Random Chess with randomized starting positions
- Interactive GUI: User-friendly graphical interface built with Java Swing
- Mouse Controls: Click-and-drag piece movement
- Game Validation: Complete move validation and game state checking
- Check/Checkmate Detection: Automatic detection of check, checkmate, and stalemate
- Piece Promotion: Pawn promotion to Queen, Rook, Bishop, or Knight
- Castling: Support for both kingside and queenside castling
- En Passant: Special pawn capture rule implementation
- Java: JDK 17 or higher
- Operating System: Windows, macOS, or Linux
- Memory: 512 MB RAM minimum
- Display: 800x600 minimum resolution
-
Clone the repository:
git clone https://github.com/snxethan/PRO250-CHESS.git cd PRO250-CHESS -
Compile the project:
mkdir -p build javac -cp src -d build src/main/*.java src/piece/*.java
-
Run the game:
java -cp build:res main.Main
- Open IntelliJ IDEA
- Select "Open" and choose the project directory
- The project should load automatically with the existing
.imlconfiguration - Run the
Main.javaclass
- Launch the application
- Choose between:
- Standard Chess: Traditional chess with standard starting positions
- Chess960: Fischer Random Chess with randomized piece positions
- Move Pieces: Click on a piece to select it, then click on the destination square
- Piece Selection: Valid moves are highlighted when a piece is selected
- Promotion: When a pawn reaches the opposite end, choose the promotion piece
- New Game: Restart the application to start a new game
The game follows standard FIDE chess rules including:
- Standard piece movements (King, Queen, Rook, Bishop, Knight, Pawn)
- Special moves: Castling, En Passant, Pawn Promotion
- Win conditions: Checkmate
- Draw conditions: Stalemate
PRO250-CHESS/
├── src/
│ ├── main/
│ │ ├── Main.java # Application entry point
│ │ ├── GamePanel.java # Main game logic and rendering
│ │ ├── Board.java # Chess board representation
│ │ ├── Mouse.java # Mouse input handling
│ │ ├── StartScreen.java # Start menu interface
│ │ └── Type.java # Piece type enumeration
│ ├── piece/
│ │ ├── Piece.java # Base piece class
│ │ ├── King.java # King piece implementation
│ │ ├── Queen.java # Queen piece implementation
│ │ ├── Rook.java # Rook piece implementation
│ │ ├── Bishop.java # Bishop piece implementation
│ │ ├── Knight.java # Knight piece implementation
│ │ └── Pawn.java # Pawn piece implementation
│ └── test/
│ └── java/
│ └── main/ # Test classes (JUnit)
├── res/
│ ├── chess.png # Chess piece sprite sheet
│ └── piece/ # Individual piece images
├── out/ # Compiled output directory
├── .idea/ # IntelliJ IDEA configuration
├── ChessGame.iml # IntelliJ IDEA module file
└── README.md # This file
The project follows an object-oriented design with clear separation of concerns:
- Main Package: Contains the main application logic, UI components, and game management
- Piece Package: Contains individual chess piece implementations with their specific movement rules
- Resource Management: Images and assets are loaded from the
res/directory
GamePanel: Core game engine handling game state, piece movement, and renderingBoard: Represents the chess board and provides utility methods for board operationsPiece: Abstract base class for all chess pieces with common functionality- Individual piece classes: Implement specific movement patterns and rules
The project includes JUnit test infrastructure. Tests can be run using:
# Compile tests
javac -cp src:build:/path/to/junit-4.13.1.jar -d build src/test/java/main/*.java
# Run tests (if test files exist)
java -cp build:/path/to/junit-4.13.1.jar org.junit.runner.JUnitCore main.TestClassName- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Java naming conventions
- Add JavaDoc comments for public methods
- Maintain consistent indentation and formatting
- Write unit tests for new functionality
This project is part of the PRO250 course curriculum. Please check with the course instructor regarding usage and distribution rights.
- Chess piece images and sprites used in the game
- Java Swing framework for GUI implementation
- JUnit framework for testing infrastructure