Super IA #5
@@ -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<Move> 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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user