From 0b15f1e2879072f44f60e637132dd5cf04c8c85a Mon Sep 17 00:00:00 2001 From: djib Date: Wed, 4 Jan 2006 19:37:48 +0000 Subject: [PATCH] TestXBoardProtocol hasn't changed much. Now it is in a package called test. NEW FILE: TestMoves -> purpose is to test the Move class NEW FILE: Move -> this is a first implementation of a simple class that reads a string and converts it to a move or the opposite. NEW FILE: BitBoard -> this class really doesn't do anything yet. It only has definition of 14 bitboards but they are not created yet. --- src/suicideChess/BitBoard.java | 86 ++++++++++++++++++++++ src/suicideChess/Move.java | 96 +++++++++++++++++++++++++ src/tests/TestMoves.java | 34 +++++++++ src/{ => tests}/TestXBoardProtocol.java | 22 ++++-- 4 files changed, 231 insertions(+), 7 deletions(-) create mode 100644 src/suicideChess/BitBoard.java create mode 100644 src/suicideChess/Move.java create mode 100644 src/tests/TestMoves.java rename src/{ => tests}/TestXBoardProtocol.java (78%) diff --git a/src/suicideChess/BitBoard.java b/src/suicideChess/BitBoard.java new file mode 100644 index 0000000..f111e4b --- /dev/null +++ b/src/suicideChess/BitBoard.java @@ -0,0 +1,86 @@ +package suicideChess; + +/** + * @author djib + * + * This file contains the board representation. + * The board is represented using bitboards. + * + * $LastChangedDate$ + * $LastChangedRev$ + * $LastChangedBy$ + */ + +public class BitBoard { + + /************* + * CONSTANTS * + *************/ + + //Some constants to make code more readable + public static final int NB_OF_SQUARES = 64; + + //Some constants used to access the bitboards + //Note that in suicide chess there may be more than one king + public static final int WHITE_PAWNS = 0; + public static final int BLACK_PAWNS = 1; + public static final int WHITE_KINGS = 2; + public static final int BLACK_KINGS = 3; + public static final int WHITE_QUEENS = 4; + public static final int BLACK_QUEENS = 5; + public static final int WHITE_BISHOPS = 6; + public static final int BLACK_BISHOPS = 7; + public static final int WHITE_KNIGHTS = 8; + public static final int BLACK_KNIGHTS = 9; + public static final int WHITE_ROOKS = 10; + public static final int BLACK_ROOKS = 11; + public static final int WHITE_PIECES = 12; + public static final int BLACK_PIECES = 13; + + public static final int NB_OF_BITBOARDS = 14; + + + /******** + * DATA * + ********/ + + //The following table is used to map squares to bits + private static long mapSquaresToBits[]; + + //static function used to initialise data + static { + mapSquaresToBits = new long[NB_OF_SQUARES]; + for(int i=0; iquit;"); - // break; - //} + System.err.println(xBoardCommand); + if (xBoardCommand.startsWith("quit")) { + logger.info(">quit;"); + break; + } if (xBoardCommand.startsWith("otim")) { logger.info(">Error"); System.out.println("Error (unknown command): time"); } if (xBoardCommand.startsWith("e2e4")) { - logger.info(">move b8c6"); + logger.info(">move b8b8"); System.out.println("move b8c6"); } if (xBoardCommand.startsWith("d2d4")) {