Before a big change in the code : different value for each piece

This commit is contained in:
2006-06-30 15:34:22 +00:00
parent 95deacff45
commit e9d5fe78a7
3 changed files with 20 additions and 19 deletions

View File

@ -85,6 +85,9 @@ public class Board {
private int numberOfBlackPieces = NB_OF_FILES*2; private int numberOfBlackPieces = NB_OF_FILES*2;
private int numberOfWhitePieces = 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 boardValue = 0; //evaluation of the board value
private int currentPlayer; //color of the current player. private int currentPlayer; //color of the current player.

View File

@ -66,12 +66,12 @@ public class ComputerPlayer {
private static int MinMax(Board bitboard, int currentDepth) throws NotAValidSquare, NoPieceOnSquare { private static int MinMax(Board bitboard, int currentDepth) throws NotAValidSquare, NoPieceOnSquare {
nodesSearched++;
if (currentDepth >= SuicideChess.PLY_DEPTH) { if (currentDepth >= SuicideChess.PLY_DEPTH) {
return bitboard.getBoardValue(); return bitboard.getBoardValue();
} }
nodesSearched++;
Rules.legalMovesForPlayer(bitboard); Rules.legalMovesForPlayer(bitboard);
ArrayList<Move> allLegalMoves = Rules.getLegalMovesCapture(); ArrayList<Move> allLegalMoves = Rules.getLegalMovesCapture();
if (allLegalMoves.size()==0) { if (allLegalMoves.size()==0) {
@ -171,11 +171,11 @@ public class ComputerPlayer {
public int getBranchValue() {return this.branchValue;} public int getBranchValue() {return this.branchValue;}
}; };
private static ReturnWrapper AlphaBeta(Board bitboard, int currentDepth, int alpha, int beta) throws NotAValidSquare, NoPieceOnSquare { private static ReturnWrapper AlphaBeta(Board bitboard, int currentDepth, int alpha, int beta) throws NotAValidSquare, NoPieceOnSquare {
nodesSearched++;
if (currentDepth >= SuicideChess.PLY_DEPTH) { if (currentDepth >= SuicideChess.PLY_DEPTH) {
//System.out.println("'-> Evaluate: "+bitboard.getBoardValue()); //System.out.println("'-> Evaluate: "+bitboard.getBoardValue());
return new ReturnWrapper(bitboard.getBoardValue(),bitboard.getBoardValue()); return new ReturnWrapper(bitboard.getBoardValue(),bitboard.getBoardValue());
} }
nodesSearched++;
Rules.legalMovesForPlayer(bitboard); Rules.legalMovesForPlayer(bitboard);
ArrayList<Move> allLegalMoves = Rules.getLegalMovesCapture(); ArrayList<Move> allLegalMoves = Rules.getLegalMovesCapture();
@ -210,17 +210,17 @@ public class ComputerPlayer {
//System.out.println("| CurrentBeta, beta:" + currentAlphaBeta + ", " + beta); //System.out.println("| CurrentBeta, beta:" + currentAlphaBeta + ", " + beta);
//calculating new value of beta //calculating new value of beta
if (currentAlphaBeta<beta) { if (currentAlphaBeta<=beta) {
beta = currentAlphaBeta; beta = currentAlphaBeta;
if (currentDepth==0) {
bestMoves.clear();
//System.out.println("*** Clear ");
}
} }
//calculating branch value //calculating branch value
if (currentScore <= bestScoreSoFar) { if (currentScore <= bestScoreSoFar) {
if (currentScore < bestScoreSoFar) { if (currentScore < bestScoreSoFar) {
bestScoreSoFar=currentScore; bestScoreSoFar=currentScore;
if (currentDepth==0) {
bestMoves.clear();
//System.out.println("*** Clear ");
}
} }
if(currentDepth==0) { if(currentDepth==0) {
bestMoves.add(allLegalMoves.get(i)); bestMoves.add(allLegalMoves.get(i));
@ -229,8 +229,7 @@ public class ComputerPlayer {
} }
if(beta<alpha) { 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 return new ReturnWrapper(alpha,bestScoreSoFar); //pruning
} }
} }
@ -250,18 +249,18 @@ public class ComputerPlayer {
//System.out.println("| CurrentScore, BestScore:" + currentScore + ", " + bestScoreSoFar); //System.out.println("| CurrentScore, BestScore:" + currentScore + ", " + bestScoreSoFar);
//System.out.println("| CurrentAlpha, alpha:" + currentAlphaBeta + ", " + alpha); //System.out.println("| CurrentAlpha, alpha:" + currentAlphaBeta + ", " + alpha);
//calculating new value of beta //calculating new value of alpha
if (currentAlphaBeta>alpha) { if (currentAlphaBeta>=alpha) {
alpha = currentAlphaBeta; alpha = currentAlphaBeta;
if (currentDepth==0) {
bestMoves.clear();
//System.out.println("*** Clear ");
}
} }
//calculating branch value //calculating branch value
if (currentScore >= bestScoreSoFar) { if (currentScore >= bestScoreSoFar) {
if (currentScore > bestScoreSoFar) { if (currentScore > bestScoreSoFar) {
bestScoreSoFar=currentScore; bestScoreSoFar=currentScore;
if (currentDepth==0) {
bestMoves.clear();
//System.out.println("*** Clear ");
}
} }
if(currentDepth==0) { if(currentDepth==0) {
bestMoves.add(allLegalMoves.get(i)); bestMoves.add(allLegalMoves.get(i));
@ -270,8 +269,7 @@ public class ComputerPlayer {
} }
if(alpha>beta) { 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 return new ReturnWrapper(beta,bestScoreSoFar); //pruning
} }
} }

View File

@ -38,7 +38,7 @@ public class SuicideChess {
/** /**
* Displays informations in the console. * 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 * Number of Plies the computes searches to