› jenish_patel
All Projects
Systems2023

Java Chess Engine

Fully playable two-player console chess engine in Java implementing the complete rule set: all 6 piece types with legal move validation, check and checkmate detection, en passant, castling with first-move tracking, pawn promotion to any piece, draw offer, and resign.

Key Metric

Full rule set: en passant · castling · checkmate detection · pawn promotion

01

Overview

A complete command-line chess game where two players enter moves in algebraic notation (e.g. 'e2 e4'). The engine validates every move against the full FIDE rule set, renders the board after each turn with rank/file labels, detects check after every move, and terminates on checkmate or resignation. Pawn promotion supports all four target pieces (Queen, Rook, Bishop, Knight). En passant is tracked with a per-turn state flag, and castling respects the firstMove constraint on both King and Rook.

02

Architecture & Approach

The design is a clean OOP hierarchy: an abstract pieces base class defines the contract (isValid, drawPiece, isWhite, firstMove), with six concrete subclasses — Pawn, Knight, Bishop, Rook, Queen, King — each implementing their own movement validation. The 8×8 board is a static pieces[][] array on chessBoard. Check detection scans the full board for any opponent piece whose isValid + isClearPath would reach the King. Checkmate is confirmed when the King has no legal escape that resolves check. En passant is implemented with a coordinate-level state machine that sets capture coordinates on double-pawn advances and validates the capture on the following move. Algebraic input is parsed with StringTokenizer and mapped to array coordinates via file-to-index and rank-to-index conversions.

03

Results & Outcome

Fully playable two-player chess with all standard rules implemented. Check is announced each turn, checkmate terminates the game with a winner declaration, and all special moves (en passant, castling, promotion) function correctly. The OOP piece hierarchy keeps movement logic encapsulated per-piece and extensible.

Tech Stack

JavaOOPGame LogicAlgorithms2D Arrays