Before a big change in the code : different value for each piece
This commit is contained in:
@ -85,6 +85,9 @@ public class Board {
|
||||
|
||||
private int numberOfBlackPieces = NB_OF_FILES*2;
|
||||
private int numberOfWhitePieces = NB_OF_FILES*2;
|
||||
private int[] numberOfPieces = new int[Piece.MAX_PIECE_NUMBER];
|
||||
{ numberOfPieces[Piece.BLACK_BISHOP]=2;
|
||||
}
|
||||
private int boardValue = 0; //evaluation of the board value
|
||||
|
||||
private int currentPlayer; //color of the current player.
|
||||
|
@ -66,12 +66,12 @@ public class ComputerPlayer {
|
||||
|
||||
|
||||
private static int MinMax(Board bitboard, int currentDepth) throws NotAValidSquare, NoPieceOnSquare {
|
||||
nodesSearched++;
|
||||
|
||||
if (currentDepth >= SuicideChess.PLY_DEPTH) {
|
||||
return bitboard.getBoardValue();
|
||||
}
|
||||
|
||||
nodesSearched++;
|
||||
|
||||
Rules.legalMovesForPlayer(bitboard);
|
||||
ArrayList<Move> allLegalMoves = Rules.getLegalMovesCapture();
|
||||
if (allLegalMoves.size()==0) {
|
||||
@ -171,11 +171,11 @@ public class ComputerPlayer {
|
||||
public int getBranchValue() {return this.branchValue;}
|
||||
};
|
||||
private static ReturnWrapper AlphaBeta(Board bitboard, int currentDepth, int alpha, int beta) throws NotAValidSquare, NoPieceOnSquare {
|
||||
nodesSearched++;
|
||||
if (currentDepth >= SuicideChess.PLY_DEPTH) {
|
||||
//System.out.println("'-> Evaluate: "+bitboard.getBoardValue());
|
||||
return new ReturnWrapper(bitboard.getBoardValue(),bitboard.getBoardValue());
|
||||
}
|
||||
nodesSearched++;
|
||||
|
||||
Rules.legalMovesForPlayer(bitboard);
|
||||
ArrayList<Move> allLegalMoves = Rules.getLegalMovesCapture();
|
||||
@ -210,17 +210,17 @@ public class ComputerPlayer {
|
||||
//System.out.println("| CurrentBeta, beta:" + currentAlphaBeta + ", " + beta);
|
||||
|
||||
//calculating new value of beta
|
||||
if (currentAlphaBeta<beta) {
|
||||
if (currentAlphaBeta<=beta) {
|
||||
beta = currentAlphaBeta;
|
||||
if (currentDepth==0) {
|
||||
bestMoves.clear();
|
||||
//System.out.println("*** Clear ");
|
||||
}
|
||||
}
|
||||
//calculating branch value
|
||||
if (currentScore <= bestScoreSoFar) {
|
||||
if (currentScore < bestScoreSoFar) {
|
||||
bestScoreSoFar=currentScore;
|
||||
if (currentDepth==0) {
|
||||
bestMoves.clear();
|
||||
//System.out.println("*** Clear ");
|
||||
}
|
||||
}
|
||||
if(currentDepth==0) {
|
||||
bestMoves.add(allLegalMoves.get(i));
|
||||
@ -229,8 +229,7 @@ public class ComputerPlayer {
|
||||
}
|
||||
|
||||
if(beta<alpha) {
|
||||
if(currentDepth != 3)
|
||||
System.out.println("Pruning "+Integer.toString(allLegalMoves.size()-i)+" alternatives at depth "+ currentDepth);
|
||||
//System.out.println("Pruning "+Integer.toString(allLegalMoves.size()-i)+" alternatives at depth "+ currentDepth);
|
||||
return new ReturnWrapper(alpha,bestScoreSoFar); //pruning
|
||||
}
|
||||
}
|
||||
@ -250,18 +249,18 @@ public class ComputerPlayer {
|
||||
//System.out.println("| CurrentScore, BestScore:" + currentScore + ", " + bestScoreSoFar);
|
||||
//System.out.println("| CurrentAlpha, alpha:" + currentAlphaBeta + ", " + alpha);
|
||||
|
||||
//calculating new value of beta
|
||||
if (currentAlphaBeta>alpha) {
|
||||
//calculating new value of alpha
|
||||
if (currentAlphaBeta>=alpha) {
|
||||
alpha = currentAlphaBeta;
|
||||
if (currentDepth==0) {
|
||||
bestMoves.clear();
|
||||
//System.out.println("*** Clear ");
|
||||
}
|
||||
}
|
||||
//calculating branch value
|
||||
if (currentScore >= bestScoreSoFar) {
|
||||
if (currentScore > bestScoreSoFar) {
|
||||
bestScoreSoFar=currentScore;
|
||||
if (currentDepth==0) {
|
||||
bestMoves.clear();
|
||||
//System.out.println("*** Clear ");
|
||||
}
|
||||
}
|
||||
if(currentDepth==0) {
|
||||
bestMoves.add(allLegalMoves.get(i));
|
||||
@ -270,8 +269,7 @@ public class ComputerPlayer {
|
||||
}
|
||||
|
||||
if(alpha>beta) {
|
||||
if(currentDepth != 3)
|
||||
System.out.println("Pruning "+Integer.toString(allLegalMoves.size()-i)+" alternatives at depth "+ currentDepth);
|
||||
//System.out.println("Pruning "+Integer.toString(allLegalMoves.size()-i)+" alternatives at depth "+ currentDepth);
|
||||
return new ReturnWrapper(beta,bestScoreSoFar); //pruning
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class SuicideChess {
|
||||
/**
|
||||
* Displays informations in the console.
|
||||
*/
|
||||
public static final boolean ASCII_GAME = false;
|
||||
public static final boolean ASCII_GAME = true;
|
||||
|
||||
/**
|
||||
* Number of Plies the computes searches to
|
||||
|
Reference in New Issue
Block a user