The computer plays with minmax and detects the end of games
No known bugs
This commit is contained in:
2006-01-27 23:34:09 +00:00
parent 5266b582bb
commit 213b1e3bf0
8 changed files with 225 additions and 193 deletions

View File

@ -16,13 +16,6 @@ public class ComputerPlayer {
/**
* This constructor creates a computer.
*/
public ComputerPlayer() {
//this.color = color;
}
/**
* This asks the computer to compute a move
* @param bitboard The current status of the {@link Board}
@ -32,7 +25,7 @@ public class ComputerPlayer {
* @see Board
* @see Move
*/
public Move doRandomMove(Board bitboard, int color) throws NotAValidSquare {
public static Move doRandomMove(Board bitboard, int color) throws NotAValidSquare {
Random generator = new Random();
Rules.legalMovesForPlayer(bitboard,color);
ArrayList<Move> allLegalMoves = Rules.getLegalMovesCapture();
@ -57,14 +50,14 @@ public class ComputerPlayer {
* @see Board
* @see Move
*/
public Move doMinMaxMove(Board bitboard, int color) throws NotAValidSquare, NoPieceOnSquare {
public static Move doMinMaxMove(Board bitboard, int color) throws NotAValidSquare, NoPieceOnSquare {
bestMove = null;
MinMax(bitboard, color, 0);
return bestMove;
}
private int MinMax(Board bitboard, int color, int currentDepth) throws NotAValidSquare, NoPieceOnSquare {
private static int MinMax(Board bitboard, int color, int currentDepth) throws NotAValidSquare, NoPieceOnSquare {
if (currentDepth >= SuicideChess.PLY_DEPTH) {
return bitboard.getBoardValue();
}