Quelques modifications mineures
This commit is contained in:
@ -33,7 +33,7 @@ public class SuicideChess {
|
||||
/**
|
||||
* The name to be displayed
|
||||
*/
|
||||
public static final String NAME = "djib's SuicideChess v0.4.1";
|
||||
public static final String NAME = "djib's SuShi (Suicide Chess) v0.4.3";
|
||||
|
||||
/**
|
||||
* Displays informations in the console.
|
||||
@ -197,7 +197,7 @@ public class SuicideChess {
|
||||
}
|
||||
//if XBoard did not accept usermove command we try and interpret every unknown command
|
||||
//as a move.
|
||||
case XBoardProtocol.MOVE:
|
||||
case XBoardProtocol.MOVE:
|
||||
Move theMove;
|
||||
if (acceptedUsermove) {
|
||||
theMove = new Move(whatMove.substring(9), bitboard);
|
||||
@ -205,6 +205,13 @@ public class SuicideChess {
|
||||
theMove = new Move(whatMove, bitboard);
|
||||
}
|
||||
|
||||
if (testWinningPosition(bitboard)) {
|
||||
//if board was set in an illegal position
|
||||
System.out.println("Illegal move: "+theMove.toString());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
boolean needToCapture = false;
|
||||
int foundMoveIndex = -1;
|
||||
if(theMove.getMovingPiece().getColor() == bitboard.getCurrentPlayer()) {
|
||||
@ -258,9 +265,16 @@ public class SuicideChess {
|
||||
case XBoardProtocol.GO:
|
||||
//this is not really nice but it avoids having to write twice the code
|
||||
//I check if I did really receive a XBoardProtocol.GO or it I just got there
|
||||
//because there is no break statement.
|
||||
//because there is no break statement.
|
||||
if (xBoardCommand==XBoardProtocol.GO)
|
||||
computerPlaying = true;
|
||||
|
||||
if (testWinningPosition(bitboard)) {
|
||||
//in case an illegal position have been sent
|
||||
computerPlaying=false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (computerPlaying) {
|
||||
Move computerMove = ComputerPlayer.doMinMaxMove(bitboard);
|
||||
bitboard.doMove(computerMove);
|
||||
@ -272,6 +286,7 @@ public class SuicideChess {
|
||||
bitboard.display();
|
||||
}
|
||||
}
|
||||
|
||||
if (testWinningPosition(bitboard)) {
|
||||
computerPlaying=false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user