v0.4.1
The computer plays with minmax and detects the end of games No known bugs
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user