A simple Java chess implementation built for learning and experimentation. The projects includes piece and board display, player implementations (human and AI), and a Game runner.
- Java 17 or newer
Open a terminal in the project root and compile all source files:
javac *.javaRun the game:
java GameThe Game class is the application entry point. When launched, it creates a game instance and uses BoardDisplay to render the chess board and handle user interaction.
When the game starts, you will be prompted to configure both White and Black players.
For each side, choose:
- A player type:
human,smart, orrandom - A player name
Press Enter to accept the default values (human with names White/Black).
Example:
White player type (human/smart/random) [human]: smart
White player name [White]: Bot
Black player type (human/smart/random) [human]: human
Black player name [Black]: Alice
Allows a user to make moves through the graphical board interface.
If a side is configured as a human player:
- Click the piece you want to move.
- The selected piece should highlight.
- Click a valid destination square.
When it is a human player's turn, the game will also display a terminal message such as:
White player's turn: Alice
Chooses a legal move uniformly at random from all available moves.
Uses a minimax-style search algorithm to evaluate future positions.
The algorithm executes the following steps:
- Evaluates current position by value (piece count and strength)
- Simulates future move sequences
- Chooses the move with the best worst-case outcome
- Searches several plies deep (currently 4 plies by default)
Game.java— application entry point and game loopBoard.java— chess board implementationMove.java— move representationLocation.java— board coordinates
Grid.javaAbstractGrid.javaBoundedGrid.java
These classes provide the underlying grid abstraction used by the board.
Piece.javaKing.javaQueen.javaRook.javaBishop.javaKnight.javaPawn.java
Each piece class defines its movement behavior and legal move generation.
Player.javaHumanPlayer.javaRandomPlayer.javaSmartPlayer.java
These classes define the available player implementations.
BoardDisplay.java— graphical board display and user interaction handling
Possible improvements include more advanced AI search and evaluation functions, alpha-beta pruning, opening books, additional chess rules and edge cases, and enhanced UI features.
This project was created as a course project for AP Computer Science with Data Structures (2023).
Linda Zeng
This project is licensed under the MIT License. See the LICENSE file for details.
