A two-player chess game built in Java that implements the complete rules of chess with a focus on clean object-oriented design and rule validation. The project manages board state, piece movement, and game flow while enforcing complex mechanics such as check, checkmate, stalemate, castling, en passant, and pawn promotion, all executed through a terminal-based interface. ♟️
This section guides you through installing and running chess for the first time. We'll use Java 21.0+ as the example environment.
Before diving in, ensure you have the following installed:
- [Language/Runtime]: Java 21.0+ (check with
java --version). - [Other Tools]:
- Git.
If you're missing anything, follow the linked install guides—they're quick.
-
Clone the Repository:
git clone https://github.com/HimanshuPadecha/Chess cd Chess -
Compile and Run:
javac Main.java java Main
The chess board is represented as an 8×8 structure of squares. ♟️
Each square contains a position and optionally a chess piece.
Board
└── Map<Rank, List<Square>>
└── Square
├── Position (rank, file)
└── Piece (optional)
| File | Responsibility |
|---|---|
Main.java |
Entry point of the application |
Chess.java |
Controls game flow and turn management |
Board.java |
Represents and manages the chess board |
Square.java |
Represents a single board square |
Positon.java |
Stores rank and file coordinates |
Piece.java |
Base abstraction for chess pieces |
PIECES.java |
Enum representing piece types |
COLORS.java |
Enum representing piece colors |
ValidateMoves.java |
Validates legal moves |
Attacking.java |
Calculates attacking squares |
AttackingInfo.java |
Stores attack information |
PrevMove.java |
Tracks previous move information |
Utils.java |
Utility helper methods |
IllegalMove.java |
Exception for illegal moves |
InvalidPosition.java |
Exception for invalid positions |
InvalidSquare.java |
Exception for invalid square input |
Kindly check this PDF: 📄 Detailed Algorithms