smarter
This commit is contained in:
@@ -38,13 +38,9 @@ public class AlphaBetaThread extends Thread {
|
|||||||
|
|
||||||
private float getEndGameEvaluation() {
|
private float getEndGameEvaluation() {
|
||||||
Color currentTurn = this.simulation.getPlayerTurn();
|
Color currentTurn = this.simulation.getPlayerTurn();
|
||||||
if (currentTurn == this.color) {
|
if (this.simulation.getBoard().isKingInCheck(currentTurn))
|
||||||
return HORRIBLE_MOVE;
|
return GREAT_MOVE;
|
||||||
} else {
|
return getBoardEvaluation() - PieceCost.PAWN;
|
||||||
if (this.simulation.getBoard().isKingInCheck(currentTurn))
|
|
||||||
return GREAT_MOVE;
|
|
||||||
return getBoardEvaluation() + PieceCost.PAWN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getBoardEvaluation() {
|
private float getBoardEvaluation() {
|
||||||
@@ -57,8 +53,6 @@ public class AlphaBetaThread extends Thread {
|
|||||||
result += pieceCost.getCost(piece) + piecePosCost.getEvaluation(piece, coordinate);
|
result += pieceCost.getCost(piece) + piecePosCost.getEvaluation(piece, coordinate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.simulation.getPlayerTurn() != color)
|
|
||||||
return -result;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,9 +64,6 @@ public class AlphaBetaThread extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private float negaMax(int depth, float alpha, float beta) {
|
private float negaMax(int depth, float alpha, float beta) {
|
||||||
if (depth == 0)
|
|
||||||
return getBoardEvaluation();
|
|
||||||
|
|
||||||
float value = MIN_FLOAT;
|
float value = MIN_FLOAT;
|
||||||
|
|
||||||
List<Move> moves = this.simulation.getAllowedMoves();
|
List<Move> moves = this.simulation.getAllowedMoves();
|
||||||
@@ -84,7 +75,7 @@ public class AlphaBetaThread extends Thread {
|
|||||||
|
|
||||||
for (Move move : moves) {
|
for (Move move : moves) {
|
||||||
this.simulation.tryMove(move);
|
this.simulation.tryMove(move);
|
||||||
movesCost.add(Map.entry(move, getBoardEvaluation()));
|
movesCost.add(Map.entry(move, -getBoardEvaluation()));
|
||||||
this.simulation.undoMove();
|
this.simulation.undoMove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user