From 03175f9e5b44587ad5c1c910b4c33a438b224094 Mon Sep 17 00:00:00 2001 From: "MSI-AB\\antoineB" Date: Fri, 23 May 2025 09:12:36 +0200 Subject: [PATCH] auto player update --- src/backend/AutoPlayer.java | 12 +++++------- src/backend/GameSoundManager.java | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/backend/AutoPlayer.java b/src/backend/AutoPlayer.java index 693e002..b051fc4 100644 --- a/src/backend/AutoPlayer.java +++ b/src/backend/AutoPlayer.java @@ -4,13 +4,13 @@ import java.util.ArrayList; public class AutoPlayer { - private static final int MAX_DEPTH = 2; // You can increase this for stronger AI + private final int MAX_DEPTH = 2; // Now an instance variable public Move computeBestMove(Board board) { return minimax(board, MAX_DEPTH, board.isTurnWhite()).bestMove; } - private static class ScoredMove { + private class ScoredMove { Move bestMove; int score; @@ -20,7 +20,7 @@ public class AutoPlayer { } } - private ScoredMove minimax(Board board, int depth, boolean isMaximizing) { + public ScoredMove minimax(Board board, int depth, boolean isMaximizing) { if (depth == 0) { return new ScoredMove(null, evaluateBoard(board)); } @@ -66,7 +66,7 @@ public class AutoPlayer { for (Piece piece : board.getPieces()) { if (piece.isWhite() != isWhite) continue; - ArrayList legalMoves = board.computeLegalMovesSafe(piece); + ArrayList legalMoves = board.computeLegalMoves(piece); for (int[] move : legalMoves) { Piece target = getPieceAt(board, move[0], move[1]); Move candidate = new Move( @@ -94,11 +94,9 @@ public class AutoPlayer { } } - private Piece getPieceAt(Board board, int x, int y) { for (Piece p : board.getPieces()) { if (p.getX() == x && p.getY() == y) return p; } - return null; - } + return null;} } \ No newline at end of file diff --git a/src/backend/GameSoundManager.java b/src/backend/GameSoundManager.java index 6739866..99e0240 100644 --- a/src/backend/GameSoundManager.java +++ b/src/backend/GameSoundManager.java @@ -47,5 +47,5 @@ public class GameSoundManager { if (jblClip != null) jblClip.stop(); if (backgroundClip != null) backgroundClip.stop(); -} +} } \ No newline at end of file