This is a chess game developed using Java and the Swing framework. It allows users to play a digital version of the classic chess game against another player on the same machine. The game offers an intuitive GUI, handles piece movement rules, and includes features like scorekeeping and a leaderboard to track player performance across multiple sessions.
The game is designed for two players, with white always moving first. It highlights possible moves for each selected piece, ensuring that players only make valid moves according to chess rules.
- At the start of the game, players are prompted to enter their names. These names are used to identify players and track wins.
- The game does not allow empty or duplicate names for both players.
- The game tracks wins for each player across multiple sessions. Wins are stored in permanent data files, ensuring that player stats persist even after closing the game.
- After each match, a leaderboard is displayed, showing all players who have participated and their respective win counts, ranked in descending order.
- The game highlights legal moves for a selected piece, preventing invalid moves. This ensures that players can only move pieces according to the rules of chess.
- Players can change their piece selection if needed by clicking on another piece.
- Checkmate occurs when a player's king is captured, rather than the traditional method of being placed in a checkmate position. This modification ensures both players remain vigilant during gameplay.
- Stalemate occurs when a player has no legal moves left but their king is not in check. The game is declared a tie under these conditions.
- After launching the game, two popups will appear. Enter the name of the white player in the first popup and the name of the black player in the second popup. Ensure that the names are not identical or empty.
- Once the names have been entered, the chessboard will appear with all pieces in their starting positions. White always moves first.
- To move a piece, first select it by clicking on it. The game will highlight the possible legal moves for that piece in blue.
- Click on a highlighted square to move the piece to that location.
- After the white player's move, the black player follows the same steps to make their move.
- Players alternate turns until one player checkmates the other's king or a stalemate occurs.
- Once the game ends (by checkmate or stalemate), a popup will display the outcome, declaring the winner or indicating a tie.
- After dismissing the popup, the leaderboard is shown, displaying all players and their accumulated wins.
To run the chess game, follow these steps:
-
Download the Repository:
- Clone or download the repository to your local machine by clicking on the "Download ZIP" button or by running:
git clone https://github.com/NadifRahman/ChessGame
- Clone or download the repository to your local machine by clicking on the "Download ZIP" button or by running:
-
Unzip the Files:
- Unzip the downloaded files. Inside, you will find a folder named
ChessGameand aREADME.mdfile.
- Unzip the downloaded files. Inside, you will find a folder named
-
Setting Up in NetBeans:
- Move the
ChessGamefolder to yourNetBeansProjectsdirectory, or any folder of your choice. - Launch NetBeans, navigate to
File > Open Project, and select theChessGamefolder.
- Move the
-
Run the Game:
- Press the green play button in NetBeans to start the chess game.
- Nadif Rahman
- Justin Hanna
- Charlie Li
- Mo Lin Li