Version 0.3 beta 3:
Computer can now play black and white For some reason the computer cannot play against himself. I think it must be because of force that is not understood.
This commit is contained in:
@ -33,13 +33,34 @@ public class SuicideChess {
|
||||
/**
|
||||
* The name to be displayed
|
||||
*/
|
||||
public static final String NAME = "djib's SuicideChess v0.1.9";
|
||||
public static final String NAME = "djib's SuicideChess v0.3 beta 2";
|
||||
|
||||
/**
|
||||
* Displays informations in the console.
|
||||
*/
|
||||
public static final boolean ASCII_GAME = false;
|
||||
|
||||
|
||||
/**
|
||||
* The color of the current player
|
||||
*/
|
||||
private static int currentPlayerColor = Piece.WHITE;
|
||||
|
||||
/**
|
||||
* Change the color of the current player
|
||||
*/
|
||||
private static void changeCurrentPlayerColor() {
|
||||
if(currentPlayerColor==Piece.WHITE) {
|
||||
currentPlayerColor=Piece.BLACK;
|
||||
if (ASCII_GAME)
|
||||
System.out.println("Black: ");
|
||||
} else {
|
||||
currentPlayerColor=Piece.WHITE;
|
||||
if (ASCII_GAME)
|
||||
System.out.println("White: ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The main function
|
||||
* @param args No parameters should be transmitted to this function.
|
||||
@ -51,13 +72,12 @@ public class SuicideChess {
|
||||
BufferedReader moveInput = new BufferedReader(new InputStreamReader(System.in));
|
||||
Board bitboard = new Board();
|
||||
|
||||
if (ASCII_GAME)
|
||||
if (ASCII_GAME) {
|
||||
bitboard.display();
|
||||
int currentPlayerColor = Piece.WHITE;
|
||||
if (ASCII_GAME)
|
||||
System.out.println("White: ");
|
||||
}
|
||||
|
||||
ComputerPlayer computer = new ComputerPlayer(Piece.BLACK);
|
||||
ComputerPlayer computer = new ComputerPlayer();
|
||||
|
||||
boolean playing = true;
|
||||
|
||||
@ -139,20 +159,23 @@ public class SuicideChess {
|
||||
System.out.println("Illegal move: "+theMove.toString());
|
||||
}
|
||||
|
||||
if (playedALegalMove) {
|
||||
currentPlayerColor = Piece.BLACK;
|
||||
Move computerMove = computer.doMove(bitboard);
|
||||
bitboard.doMove(computerMove);
|
||||
XBoardProtocol.doMove(computerMove);
|
||||
if (ASCII_GAME) {
|
||||
computerMove.display();
|
||||
bitboard.display();
|
||||
}
|
||||
currentPlayerColor = Piece.WHITE;
|
||||
if (ASCII_GAME)
|
||||
System.out.println("White: ");
|
||||
}
|
||||
if (!playedALegalMove) {
|
||||
break;
|
||||
}
|
||||
changeCurrentPlayerColor();
|
||||
//No break statement here on purpose.
|
||||
case XBoardProtocol.GO:
|
||||
Move computerMove = computer.doMove(bitboard,currentPlayerColor);
|
||||
bitboard.doMove(computerMove);
|
||||
XBoardProtocol.doMove(computerMove);
|
||||
if (ASCII_GAME) {
|
||||
computerMove.display();
|
||||
bitboard.display();
|
||||
}
|
||||
changeCurrentPlayerColor();
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// if (whatMove.startsWith("hint")) {
|
||||
|
Reference in New Issue
Block a user