diff --git a/app/src/main/java/chess/ai/minimax/AlphaBetaThread.java b/app/src/main/java/chess/ai/minimax/AlphaBetaThread.java index 9f32337..6e3e515 100644 --- a/app/src/main/java/chess/ai/minimax/AlphaBetaThread.java +++ b/app/src/main/java/chess/ai/minimax/AlphaBetaThread.java @@ -38,13 +38,9 @@ public class AlphaBetaThread extends Thread { private float getEndGameEvaluation() { Color currentTurn = this.simulation.getPlayerTurn(); - if (currentTurn == this.color) { - return HORRIBLE_MOVE; - } else { - if (this.simulation.getBoard().isKingInCheck(currentTurn)) - return GREAT_MOVE; - return getBoardEvaluation() + PieceCost.PAWN; - } + if (this.simulation.getBoard().isKingInCheck(currentTurn)) + return GREAT_MOVE; + return getBoardEvaluation() - PieceCost.PAWN; } private float getBoardEvaluation() { @@ -57,8 +53,6 @@ public class AlphaBetaThread extends Thread { result += pieceCost.getCost(piece) + piecePosCost.getEvaluation(piece, coordinate); } } - if (this.simulation.getPlayerTurn() != color) - return -result; return result; } @@ -70,9 +64,6 @@ public class AlphaBetaThread extends Thread { } private float negaMax(int depth, float alpha, float beta) { - if (depth == 0) - return getBoardEvaluation(); - float value = MIN_FLOAT; List moves = this.simulation.getAllowedMoves(); @@ -84,7 +75,7 @@ public class AlphaBetaThread extends Thread { for (Move move : moves) { this.simulation.tryMove(move); - movesCost.add(Map.entry(move, getBoardEvaluation())); + movesCost.add(Map.entry(move, -getBoardEvaluation())); this.simulation.undoMove(); }