add comment

This commit is contained in:
Jérôme BEDIER 2025-05-23 08:09:42 +02:00
parent 99c3a5a2e4
commit 68d1136ff1
4 changed files with 77 additions and 3 deletions

View File

@ -4,6 +4,31 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
/*
Task: Chess Autoplayer Implementation
Class name: AutoPlayer
Methods name:
- computeBestMove(Board board) - Computes and returns the best move for the current player according to a simple priority heuristic; returns null if no legal move or if a king would be captured.
- resetLastMovedPiece() - Resets the tracking of the last moved piece; to be called after a human move.
Methods output:
- The best possible move for the AI player given the current board state, or null if no legal move exists.
- Resets internal state for move tracking after a human move.
Methods works:
- Analyzes all possible moves for the current player.
- Avoids repeating the previous piece moved by the autoplayer.
- Prevents illegal moves that would result in capturing the king.
- Prioritizes moves that put the opposing king in check or bring pieces closer to the opposing king.
- Randomly selects among equal-priority moves.
- Tracks the last moved piece to avoid repetitive AI behavior.
Authors: Bédier Jérôme jerome.bedier@ecam.fr, Gardern Florian florian.gardner@ecam.fr, Leng Sidden sidden.leng@ecam.fr
Date: 05/21/2025
*/
public class AutoPlayer { public class AutoPlayer {
private Integer lastMovedPieceHash = null; // Track the last moved piece private Integer lastMovedPieceHash = null; // Track the last moved piece

View File

@ -5,9 +5,10 @@ import java.util.Stack;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
/*Task: Chess Game Board Implementation /*
Task: Chess Game Board Implementation
Class name: Board.java Class name: Board
Methods name: Methods name:
- getWidth() - Returns the width of the board as an integer - getWidth() - Returns the width of the board as an integer
@ -72,7 +73,7 @@ Methods works:
- User interaction handling - User interaction handling
- Visual board representation - Visual board representation
Authors: Bédier Jérôme jerome.bedier@ecam.fr Gardern Florian florian.gardner@ecam.fr Leng Sidden sidden.leng@ecam.fr Authors: Bédier Jérôme jerome.bedier@ecam.fr, Gardern Florian florian.gardner@ecam.fr, Leng Sidden sidden.leng@ecam.fr
Date: 05/21/2025 Date: 05/21/2025
*/ */

View File

@ -1,5 +1,34 @@
package backend; package backend;
/*
Task: Chess Special Moves Implementation
Class name: SpecialMoves
Methods name:
- promotePawn(boolean isWhite, int x, int y) - Returns a new Queen piece to replace a pawn upon reaching the promotion rank.
- isEnPassant(Board board, Move move) - Returns true if the specified move is an en passant capture.
- handleEnPassant(Board board, Move move) - Handles the en passant capture by removing the captured pawn from the board.
- updateEnPassantTracking(Board board, Move move, Piece piece) - Updates en passant square tracking after a pawn's double move.
- canCastle(Board board, Piece king, boolean isKingside) - Returns true if castling is possible (placeholder, always false).
- handleCastling(Board board, Move move, boolean isKingside) - Handles king and rook movement for castling (placeholder, no implementation).
Methods output:
- Promoted queen piece on pawn promotion.
- Boolean status for en passant and castling move possibilities.
- Updates to board state for en passant and castling.
- En passant tracking updates after pawn double moves.
Methods works:
- Pawn promotion to queen on reaching the opponent's back rank.
- Detection and execution of en passant captures.
- Tracking and resetting en passant target squares.
- (Placeholder) Castling logic including detection and execution.
Authors: Bédier Jérôme jerome.bedier@ecam.fr, Gardern Florian florian.gardner@ecam.fr, Leng Sidden sidden.leng@ecam.fr
Date: 05/21/2025
*/
public class SpecialMoves { public class SpecialMoves {
// Pawn promotion: always promotes to Queen for simplicity // Pawn promotion: always promotes to Queen for simplicity

View File

@ -4,6 +4,25 @@ import javax.sound.sampled.*;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
/*
Task: Chess Sound Effect Handling
Class name: soudEffect
Methods name:
- playCheckSound() - Plays a sound effect when the king is in check. Uses a WAV file and Java's audio system.
Methods output:
- Plays a check sound effect.
Methods works:
- Loads and plays a WAV audio file to provide audio feedback (e.g., when the king is in check).
- Handles exceptions for unsupported file formats, unavailable lines, and IO errors.
Authors: Bédier Jérôme jerome.bedier@ecam.fr, Gardern Florian florian.gardner@ecam.fr, Leng Sidden sidden.leng@ecam.fr
Date: 05/21/2025
*/
public class soudEffect { public class soudEffect {
public void playCheckSound() { public void playCheckSound() {
try { try {