working
This commit is contained in:
@@ -14,6 +14,13 @@ public class PieceCost implements PieceVisitor<Integer> {
|
||||
|
||||
private final Color player;
|
||||
|
||||
public static final int BISHOP = 3;
|
||||
public static final int KING = 90;
|
||||
public static final int KNIGHT = 3;
|
||||
public static final int PAWN = 1;
|
||||
public static final int QUEEN = 9;
|
||||
public static final int ROOK = 5;
|
||||
|
||||
public PieceCost(Color color) {
|
||||
this.player = color;
|
||||
}
|
||||
@@ -22,39 +29,39 @@ public class PieceCost implements PieceVisitor<Integer> {
|
||||
if (piece == null)
|
||||
return 0;
|
||||
int cost = visit(piece);
|
||||
if (piece.getColor() == player)
|
||||
if (piece.getColor() != player)
|
||||
cost = -cost;
|
||||
return cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer visitPiece(Bishop bishop) {
|
||||
return 3;
|
||||
return BISHOP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer visitPiece(King king) {
|
||||
return 90;
|
||||
return KING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer visitPiece(Knight knight) {
|
||||
return 3;
|
||||
return KNIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer visitPiece(Pawn pawn) {
|
||||
return 1;
|
||||
return PAWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer visitPiece(Queen queen) {
|
||||
return 9;
|
||||
return QUEEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer visitPiece(Rook rook) {
|
||||
return 5;
|
||||
return ROOK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user