Java
Java
(314317)
Academic year 2024-25
Micro-project
SARASWATI EDUCATION SOCIETY
YADAVRAO TASGAONKAR
POLYTECHNIC
Project Report On
“CHESS GAME”
For The Subject
JAVA PROGRAMMING
Academic Year
2024 – 2025
Affiliated to
MAHARASHTRA STATE BOARD OF TECHNICAL
EDUCATION
GROUP MEMBERS
GUIDED BY
MISS. SAYALI PATIL
MAHARASHTRA STATE BOARD OF TECHNICAL
EDUCATION
Certificate
This is to certify that Ms.SOHAM RAJARAM BHAT. Roll No.: 25of
forth Semester of Diploma in Computer engineering of Institute
Yadavrao Tasgaonkar Polytechnic (Code:0960) has completed the term
work satisfactorily in JAVA PROGRAMMING (314317) for the
academic year 2024 To 2025 as Prescribed in curriculum .
Certificate
This is to certify that Ms.HARSHAL VASUDEV PAKHARE . Roll No.:
27of forth Semester of Diploma in Computer engineering of Institute
Yadavrao Tasgaonkar Polytechnic (Code:0960) has completed the term
work satisfactorily in JAVA PROGRAMMING (314317) for the
academic year 2024 To 2025 as Prescribed in curriculum.
Certificate
This is to certify that Ms.PRATHAMESH RAJESH CHAVAN. Roll
No.: 21of forth Semester of Diploma in Computer engineering of
Institute Yadavrao Tasgaonkar Polytechnic (Code:0960) has completed
the term work satisfactorily in JAVA PROGRAMMING (314317) for the
academic year 2024 To 2025 as Prescribed in curriculum.
This is to certify that the project titled “Chess Game” is a Bonafide work
carried out by student of Diploma in Computer Engineering as a part of
curriculum as prescribed by MSBTE. I hereby declare that the project work has
not formed the basis for the award previously of any Diploma, Associate ship,
Fellowship or any other similar title according to my knowledge.
Signature of students
1.
2.
3.
4.
AIMS
1. Project Setup:
Choose a Java IDE (e.g., Eclipse, NetBeans) for development.
Set up a new Java project with necessary dependencies.
Create a Git repository for version control.
2. Features to Implement:
Implement standard chess rules and regulations.
Allow two players to play against each other.
Implement check and checkmate detection.
Provide options for undo, redo, and restart.
Implement castling, en passant, and pawn promotion.
3. User Interface:
Create a graphical user interface (GUI) using Java Swing or JavaFX.
Design a user-friendly and intuitive interface.
Display game board, pieces, and player information.
4. Code Structure:
Organize code into logical packages and classes.
Implement object-oriented programming (OOP) principles.
Use design patterns and principles for maintainable code.
ACKNOWLEDGEMENT
We extend our special thanks to all teaching and non-teaching staff. Success is
nourished under the combination of perfect guidance, care and blessing.
Acknowledgement is the best way to convey Last few years spend in estimated
institution has molded us into confident and aspiring engineers. We express our
sense of gratitude towards our project guide Miss. Sayali Patil. It is because
of her valuable guidance, analytical approach encouragement that we could
learn, work and complete the project. We will always cherish great experience
work under the enthusiastic guidance.
We are also grateful to our principal and our vice principal who not only
supported us in our project but also encouraged for every creative activity. We
also sincerely give thanks to our head of department. Mrs. Sayali Atkar of
computer and its sector, friends and well-wishers to directly or indirectly
contribute for the success of our maiden mission.
INDEX
1 INTODUCTION 1
2 THEORETICAL BACKGROUND 2
3 OBJECTIVE 4
4 CODE 5
5 OUTPUT 14
6 ANALYSIS 15
7 LIMITATION 16
8 CONCLUSION 17
9 REFERENCE 18
INTRODUCTION
1. Basic Structure
• Classes: Create essential classes such as Board, Piece, Player, Game,
and individual piece classes (e.g., King, Queen, Pawn, etc.).
• Board: Represent the 8x8 grid of the chessboard, typically using a 2D
array.
2. Board Representation
• The chessboard is typically a grid (8x8), and each square can hold a
piece or be empty.
• Use a 2D array (Piece[][] board = new Piece[8][8];) to represent the
board.
3. Piece Movement
• Implement each piece’s movement rules (e.g., rooks move
horizontally/vertically, bishops diagonally, etc.).
• For each piece, create a canMove() method that validates whether a
move is legal.
4. Player Interaction
• Two players can be implemented (one for white and one for black).
• Each player takes turns selecting a piece and moving it to a valid
square.
• Keep track of the player’s turn and switch turns after each valid
move.
THEORETICAL BACKGROUND
2. Piece Movement
• Pawn: Moves one square forward, but captures diagonally. On its first
move, a pawn can move two squares forward.
• Knight: Moves in an "L" shape (two squares in one direction and one
square perpendicular).
• Bishop: Moves diagonally any number of squares.
• Rook: Moves horizontally or vertically any number of squares.
• Queen: Combines the movement of the rook and bishop (vertically,
horizontally, and diagonally).
• King: Moves one square in any direction.
3. Special Moves
• Castling: The king and a rook can move simultaneously under specific
conditions.
• En Passant: A special pawn capture when an opponent moves a pawn
two squares forward from its starting position, passing an adjacent
pawn.
4. Game Phases
• Opening: The initial phase where players develop their pieces.
• Middle Game: Players engage in tactics and positioning to improve
the board and target weaknesses.
• Endgame: The final phase where fewer pieces are on the board and the
goal is to checkmate the opponent.
5. Game Status
• Check: The king is under direct attack and must move or be defended.
• Checkmate: The king is under attack and has no legal move to escape.
• Stalemate: The player whose turn it is has no legal move and the king
is not in check (a draw).
• Draw: The game can also end in a draw by insufficient material,
threefold repetition, or the fifty-move rule.
OBJECTIVES
public ChessBoard() {
board = new Piece[BOARD_SIZE][BOARD_SIZE];
pieceImages = new HashMap<>();
loadImages();
setupBoard();
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (!gameOver) {
int row = e.getY() / TILE_SIZE;
int col = e.getX() / TILE_SIZE;
handleClick(row, col);
repaint();
} }
});
}
private boolean canAttack(int fromRow, int fromCol, int toRow, int toCol) {
Piece piece = board[fromRow][fromCol];
return isValidMove(piece, fromRow, fromCol, toRow, toCol);
}
private void showWinningMessage() {
String winner = whiteTurn ? "White" : "Black";
JOptionPane.showMessageDialog(this, winner + " wins by checkmate!",
"Game Over", JOptionPane.INFORMATION_MESSAGE);
}
class Piece {
String type;
boolean isWhite;
Gameplay Mechanics
▪ Turn-based system: Players take turns moving one piece at a time.
▪ Piece movement: Each piece has unique movement rules (e.g., knight's
L- shape, bishop's diagonal).
▪ Capturing: Pieces capture by landing on occupied squares.
▪ Special moves: Castling, en passant, and promotion add complexity.
▪ Check and checkmate: The objective is to checkmate the opponent's
king.
Strategy Elements
▪ Control of the center: The center squares are the most important on the
board.
▪ Pawn structure: Pawn placement affects piece mobility and overall
strategy.
▪ Piece development: Moving pieces out from their starting positions to
attack and defend.
▪ Protection of the king: Castling and placing pieces in front of the king
to block attacks.
▪ Attack and counterattack: Creating threats and responding to
opponent's threats.
Player Interaction
▪ Anticipation: Players anticipate their opponent's moves and plan
accordingly.
▪ Adaptation: Players adjust their strategy based on their opponent's
moves.
LIMITATIONS
Technical Limitations
1. Complexity of chess algorithms
2. Limited AI capability
3. Graphical User Interface (GUI) limitations
4. Limited support for chess variants
Performance Limitations
1. Slow performance
2. Limited multithreading
3. High memory usage
Functional Limitations
1. Limited game modes
2. No online multiplayer
3. Limited analysis tools
4. No support for chess engines
5. Limited undo/redo functionality
Online Resources
1. GeeksforGeeks - Chess Game in Java
2. CodeProject - Java Chess Game
3. GitHub - Java Chess Engine
*****************************