Version 0.1.9

Rules are checked and en passant works.

Does not check if black or white is playing.
Does not check multiple possibilities for promotion.
This commit is contained in:
2006-01-13 12:29:54 +00:00
parent eb0e593ee1
commit c62bdacb9f
5 changed files with 233 additions and 29 deletions

View File

@ -30,15 +30,17 @@ public class SuicideChess {
public static final boolean SQUARE_CHECK_INVALID = true;
private static final int MAIN_VERSION_NUMBER = 0;
private static final int REVISION_NUMBER = 15;
private static final int REVISION_NUMBER = 17;
/**
* The main function
* @param args No parameters should be transmitted to this function.
*/
public static void main(String[] args) {
System.out.println("Welcome to SuicideChess v"+MAIN_VERSION_NUMBER+"."+REVISION_NUMBER+"!");
BufferedReader moveInput = new BufferedReader(new InputStreamReader(System.in));
System.out.println(" Welcome to SuicideChess v"+MAIN_VERSION_NUMBER+"."+REVISION_NUMBER+"!");
System.out.println();
BufferedReader moveInput = new BufferedReader(new InputStreamReader(System.in));
try {
Board bitboard = new Board();
@ -66,13 +68,35 @@ public class SuicideChess {
}
continue;
}
if (whatMove.startsWith("force")) {
Move theMove = new Move(whatMove.substring(6,10), bitboard);
theMove.display();
bitboard.doMove(theMove);
bitboard.display();
continue;
}
Move theMove = new Move(whatMove, bitboard);
theMove.display();
bitboard.doMove(theMove);
bitboard.display();
Rules rules = new Rules();
ArrayList<Move> allLegalMoves =
rules.legalMovesFromSquare(new Square(whatMove.substring(0,2)),bitboard);
int foundMoveIndex = -1;
for (int moveIndex = 0; moveIndex < allLegalMoves.size(); moveIndex++) {
if (allLegalMoves.get(moveIndex).toSquare().isEqual(theMove.toSquare())) {
foundMoveIndex=moveIndex;
break;
}
}
if (foundMoveIndex == -1) {
System.out.println("This move is not valid. Please type 'hint "+whatMove.substring(0,2)
+"' to see available moves.");
} else {
allLegalMoves.get(foundMoveIndex).display();
bitboard.doMove(allLegalMoves.get(foundMoveIndex));
bitboard.display();
}
/*if (playerColor == Piece.WHITE) {
playerColor = Piece.BLACK;
System.out.println("Black: ");