From e9d5fe78a705dfa2dc1c32e7108d111acbddb1b2 Mon Sep 17 00:00:00 2001 From: djib Date: Fri, 30 Jun 2006 15:34:22 +0000 Subject: [PATCH] Before a big change in the code : different value for each piece --- src/suicideChess/Board.java | 3 +++ src/suicideChess/ComputerPlayer.java | 34 +++++++++++++--------------- src/suicideChess/SuicideChess.java | 2 +- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/suicideChess/Board.java b/src/suicideChess/Board.java index dbdd655..92a0d6f 100644 --- a/src/suicideChess/Board.java +++ b/src/suicideChess/Board.java @@ -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. diff --git a/src/suicideChess/ComputerPlayer.java b/src/suicideChess/ComputerPlayer.java index 96d61f8..daf1dfb 100644 --- a/src/suicideChess/ComputerPlayer.java +++ b/src/suicideChess/ComputerPlayer.java @@ -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 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 allLegalMoves = Rules.getLegalMovesCapture(); @@ -210,17 +210,17 @@ public class ComputerPlayer { //System.out.println("| CurrentBeta, beta:" + currentAlphaBeta + ", " + beta); //calculating new value of beta - if (currentAlphaBetaalpha) { + //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 } } diff --git a/src/suicideChess/SuicideChess.java b/src/suicideChess/SuicideChess.java index 09b0952..924a3e6 100644 --- a/src/suicideChess/SuicideChess.java +++ b/src/suicideChess/SuicideChess.java @@ -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