diff --git a/src/suicideChess/Board.java b/src/suicideChess/Board.java index 49cd5d2..dbdd655 100644 --- a/src/suicideChess/Board.java +++ b/src/suicideChess/Board.java @@ -44,10 +44,21 @@ public class Board { */ public static final int WHITE_WINS = 99999; + /** + * Value representing the maximum value possible for the evaluation function + */ + public static final int MAX_VALUE = WHITE_WINS+1; + /** * Value returned by the evaluation function when Black wins */ public static final int BLACK_WINS = -99999; + + /** + * Value representing the minimum value possible for the evaluation function + */ + public static final int MIN_VALUE = BLACK_WINS-1; + /*======* diff --git a/src/suicideChess/ComputerPlayer.java b/src/suicideChess/ComputerPlayer.java index e3209eb..96d61f8 100644 --- a/src/suicideChess/ComputerPlayer.java +++ b/src/suicideChess/ComputerPlayer.java @@ -172,7 +172,7 @@ public class ComputerPlayer { }; private static ReturnWrapper AlphaBeta(Board bitboard, int currentDepth, int alpha, int beta) throws NotAValidSquare, NoPieceOnSquare { if (currentDepth >= SuicideChess.PLY_DEPTH) { - System.out.println("Evaluate :" + bitboard.getBoardValue()); + //System.out.println("'-> Evaluate: "+bitboard.getBoardValue()); return new ReturnWrapper(bitboard.getBoardValue(),bitboard.getBoardValue()); } nodesSearched++; @@ -184,31 +184,37 @@ public class ComputerPlayer { } if (allLegalMoves.size()==0) { if (bitboard.getCurrentPlayer()==Piece.BLACK) { - System.out.println("Evaluate :" + bitboard.getBoardValue()); + //System.out.println("'-> Evaluate *BLACK WINS*: "+Board.BLACK_WINS); return new ReturnWrapper(Board.BLACK_WINS,Board.BLACK_WINS); } else { - System.out.println("Evaluate :" + bitboard.getBoardValue()); - return new ReturnWrapper(Board.WHITE_WINS,Board.BLACK_WINS); + //System.out.println("'-> Evaluate *WHITE WINS* : "+Board.WHITE_WINS); + return new ReturnWrapper(Board.WHITE_WINS,Board.WHITE_WINS); } } else { int currentScore; int bestScoreSoFar; int currentAlphaBeta; if (bitboard.getCurrentPlayer()==Piece.BLACK) { - bestScoreSoFar=Board.WHITE_WINS+1; //any move even a WHITE_WINS will be better than that + bestScoreSoFar=Board.MAX_VALUE; //black tries to minimise for (int i=0; ialpha) { alpha = currentAlphaBeta; if (currentDepth==0) { bestMoves.clear(); + //System.out.println("*** Clear "); } } //calculating branch value @@ -251,13 +264,14 @@ public class ComputerPlayer { bestScoreSoFar=currentScore; } if(currentDepth==0) { - System.out.println("Adding move"); bestMoves.add(allLegalMoves.get(i)); + //System.out.println("*** Adding "+allLegalMoves.get(i)); } } - if(alpha>=beta) { - System.out.println("pruning"); + if(alpha>beta) { + if(currentDepth != 3) + System.out.println("Pruning "+Integer.toString(allLegalMoves.size()-i)+" alternatives at depth "+ currentDepth); return new ReturnWrapper(beta,bestScoreSoFar); //pruning } } diff --git a/src/suicideChess/SuicideChess.java b/src/suicideChess/SuicideChess.java index 0942937..09b0952 100644 --- a/src/suicideChess/SuicideChess.java +++ b/src/suicideChess/SuicideChess.java @@ -33,17 +33,17 @@ public class SuicideChess { /** * The name to be displayed */ - public static final String NAME = "djib's SuShi (Suicide Chess) v0.5"; + public static final String NAME = "djib's SuShi v0.5.2"; /** * Displays informations in the console. */ - public static final boolean ASCII_GAME = true; + public static final boolean ASCII_GAME = false; /** * Number of Plies the computes searches to */ - public static final int PLY_DEPTH = 2; + public static final int PLY_DEPTH = 4; /** * Test and display if the board is in a winning state.