pretty convincing
This commit is contained in:
@@ -17,11 +17,13 @@ import chess.model.Color;
|
||||
import chess.model.Coordinate;
|
||||
import chess.model.Game;
|
||||
import chess.model.Move;
|
||||
import chess.model.Piece;
|
||||
|
||||
public class AlphaBetaAI extends AI {
|
||||
|
||||
private final int searchDepth;
|
||||
private final PieceCost pieceCost;
|
||||
private final PiecePosCost piecePosCost;
|
||||
private final CommandExecutor simulation;
|
||||
private final Game gameSimulation;
|
||||
|
||||
@@ -32,6 +34,7 @@ public class AlphaBetaAI extends AI {
|
||||
super(commandExecutor, color);
|
||||
this.searchDepth = searchDepth;
|
||||
this.pieceCost = new PieceCost(color);
|
||||
this.piecePosCost = new PiecePosCost(color);
|
||||
this.gameSimulation = new Game();
|
||||
this.simulation = new CommandExecutor(this.gameSimulation, new EmptyGameDispatcher());
|
||||
}
|
||||
@@ -45,7 +48,9 @@ public class AlphaBetaAI extends AI {
|
||||
int result = 0;
|
||||
for (int i = 0; i < Coordinate.VALUE_MAX; i++) {
|
||||
for (int j = 0; j < Coordinate.VALUE_MAX; j++) {
|
||||
result += pieceCost.getCost(board.pieceAt(new Coordinate(i, j)));
|
||||
Coordinate coordinate = new Coordinate(i, j);
|
||||
Piece piece = board.pieceAt(coordinate);
|
||||
result += pieceCost.getCost(piece) + piecePosCost.getEvaluation(piece, coordinate);
|
||||
}
|
||||
}
|
||||
if (this.gameSimulation.getPlayerTurn() != color)
|
||||
@@ -60,7 +65,7 @@ public class AlphaBetaAI extends AI {
|
||||
} else {
|
||||
if (this.gameSimulation.getBoard().isKingInCheck(currentTurn))
|
||||
return GREAT_MOVE;
|
||||
return getBoardEvaluation() - PieceCost.PAWN;
|
||||
return getBoardEvaluation() + PieceCost.PAWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user