Exemplo n.º 1
0
 public void TestFileRaysInitialisation()
 {
     Initialiser fileRayBitboard = new Initialiser();
     UInt64[] fileRays = fileRayBitboard.InitialiseFileRays();
     TestingHelper helper = new TestingHelper();
     string fileRayBoardString = helper.BitboardToBoardString(fileRays[5]);
     Debug.WriteLine(fileRayBoardString);
 }
Exemplo n.º 2
0
 public void TestDiagonalForSquare()
 {
     TestingHelper helper = new TestingHelper();
     Initialiser bitboards = new Initialiser();
     UInt64 diag = bitboards.GetDiagonalForSquare(18);
     string boardString = helper.BitboardToBoardString(diag);
     Debug.WriteLine(boardString);
 }
Exemplo n.º 3
0
        public void TestEastRayInitialisation()
        {
            Initialiser eastRayBitboard = new Initialiser();

            UInt64[] eastRayBoard = eastRayBitboard.InitialiseEast();
            TestingHelper helper = new TestingHelper();
            string eastRayBoardString = helper.BitboardToBoardString(eastRayBoard[0]);
            Debug.WriteLine(eastRayBoardString);
        }
Exemplo n.º 4
0
 public void TestDiagonalValues()
 {
     TestingHelper helper = new TestingHelper();
     Initialiser bitboards = new Initialiser();
     UInt64[] rankDiags = bitboards.InitialiseRankDiagonals();
     UInt64 diag = rankDiags[0] << 18;
     string boardString = helper.BitboardToBoardString(diag);
     Debug.WriteLine(boardString);
 }
Exemplo n.º 5
0
 public void TestAntiDiagonals()
 {
     TestingHelper helper = new TestingHelper();
     Initialiser antiDiagsInitialiser = new Initialiser();
     UInt64[] fileAntiDiags = antiDiagsInitialiser.InitialiseFileAntiDiagonals();
     UInt64 northWestRay = fileAntiDiags[5]>>7;
     string antiDiagonalBoardString = helper.BitboardToBoardString(northWestRay);
     Debug.WriteLine(antiDiagonalBoardString);
 }
Exemplo n.º 6
0
        public void TestAntiDiagonalForSquare()
        {
            TestingHelper helper = new TestingHelper();
            Initialiser antiDiagsForSquare = new Initialiser();

            UInt64 antiDiag = antiDiagsForSquare.GetAntiDiagonalForSquare(63);
            string boardString = helper.BitboardToBoardString(antiDiag);
            Debug.WriteLine(boardString);
        }
Exemplo n.º 7
0
        public void TestFirstSquareOfDiagonal()
        {
            TestingHelper helper = new TestingHelper();
            Initialiser bitboards = new Initialiser();
            UInt64[] rankDiags = bitboards.InitialiseRankDiagonals();
            UInt64 diag = rankDiags[1];

            UInt64 firstSquare = diag & ~(diag - 1);
            // OptimiseTODO: consider bit-shifting instead of log. see http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=bitManipulation
            int firstSquareIndex = (int)Math.Log(firstSquare, 2);
            Debug.WriteLine(firstSquareIndex);
            string boardString = helper.BitboardToBoardString(firstSquare);
            Debug.WriteLine(boardString);
        }
Exemplo n.º 8
0
        public void TestMS1B()
        {
            TestingHelper testingHelper = new TestingHelper();
            Initialiser bitboards = new Initialiser();
            UInt64[] rankDiags = bitboards.InitialiseRankDiagonals();
            UInt64 diag = Constants.MainDiagonal;
                //rankDiags[1];

            BitHelper bitHelper = new BitHelper();

            UInt64 ms1b = bitHelper.GetMostSignificant1Bit(diag);
            Debug.WriteLine("Diagonal:");
            Debug.WriteLine(testingHelper.BitboardToBoardString(diag));
            Debug.WriteLine("MS1B:");
            Debug.WriteLine(testingHelper.BitboardToBoardString(ms1b));
        }
Exemplo n.º 9
0
        public void TestWestRayInitialisation()
        {
            Initialiser westRayBitboard = new Initialiser();

            UInt64[] westRayBoard = westRayBitboard.InitialiseWest();
            TestingHelper helper = new TestingHelper();
            string westRayBoardString = helper.BitboardToBoardString(westRayBoard[48]);
            Debug.WriteLine(westRayBoardString);
        }
Exemplo n.º 10
0
        public void TestSouthWestRayInitialisation()
        {
            Initialiser southWestRayBitboard = new Initialiser();

            UInt64[] southWestRayBoard = southWestRayBitboard.InitialiseSouthWest();
            TestingHelper helper = new TestingHelper();
            string southWestRayBoardString = helper.BitboardToBoardString(southWestRayBoard[34]);
            Debug.WriteLine(southWestRayBoardString);
        }
Exemplo n.º 11
0
        public void TestNorthWestRayInitialisation()
        {
            Initialiser northWestRayBitboard = new Initialiser();

            UInt64[] northWestRayBoard = northWestRayBitboard.InitialiseNorthWest();
            TestingHelper helper = new TestingHelper();
            string northWestRayBoardString = helper.BitboardToBoardString(northWestRayBoard[19]);
            Debug.WriteLine(northWestRayBoardString);
        }
Exemplo n.º 12
0
        public void TestMS1BMask()
        {
            TestingHelper testingHelper = new TestingHelper();
            Initialiser bitboards = new Initialiser();
            UInt64[] rankDiags = bitboards.InitialiseRankDiagonals();
            UInt64 diag = rankDiags[1];

            BitHelper bitHelper = new BitHelper();

            UInt64 mask = bitHelper.GetMostSignificant1BitMask(diag);
            Debug.WriteLine("Diagonal:");
            Debug.WriteLine(testingHelper.BitboardToBoardString(diag));
            Debug.WriteLine("Mask:");
            Debug.WriteLine(testingHelper.BitboardToBoardString(mask));
        }
Exemplo n.º 13
0
        public void TestMS1BIndex()
        {
            TestingHelper testingHelper = new TestingHelper();
            Initialiser bitboards = new Initialiser();
            UInt64[] rankDiags = bitboards.InitialiseRankDiagonals();
            UInt64 diag = rankDiags[1];

            BitHelper bitHelper = new BitHelper();

            int ms1bIndex = BitHelper.GetMostSignificant1BitIndex2(diag);
                // bitHelper.GetMostSignificant1BitIndex(diag);
            Debug.WriteLine("Diagonal:");
            Debug.WriteLine(testingHelper.BitboardToBoardString(diag));
        }
Exemplo n.º 14
0
        private void Initialise()
        {
            // initialise the current position board
            for (Int16 i = 0; i < 64; i++)
            {
                squareToPiece[i] = Piece.None;
            }
            squareToPiece[0] = Piece.WhiteRook;
            squareToPiece[1] = Piece.WhiteKnight;
            squareToPiece[2] = Piece.WhiteBishop;
            squareToPiece[3] = Piece.WhiteQueen;
            squareToPiece[4] = Piece.WhiteKing;
            squareToPiece[5] = Piece.WhiteBishop;
            squareToPiece[6] = Piece.WhiteKnight;
            squareToPiece[7] = Piece.WhiteRook;
            squareToPiece[8] = Piece.WhitePawn;
            squareToPiece[9] = Piece.WhitePawn;
            squareToPiece[10] = Piece.WhitePawn;
            squareToPiece[11] = Piece.WhitePawn;
            squareToPiece[12] = Piece.WhitePawn;
            squareToPiece[13] = Piece.WhitePawn;
            squareToPiece[14] = Piece.WhitePawn;
            squareToPiece[15] = Piece.WhitePawn;

            squareToPiece[63] = Piece.BlackRook;
            squareToPiece[62] = Piece.BlackKnight;
            squareToPiece[61] = Piece.BlackBishop;
            squareToPiece[60] = Piece.BlackKing;
            squareToPiece[59] = Piece.BlackQueen;
            squareToPiece[58] = Piece.BlackBishop;
            squareToPiece[57] = Piece.BlackKnight;
            squareToPiece[56] = Piece.BlackRook;
            squareToPiece[55] = Piece.BlackPawn;
            squareToPiece[54] = Piece.BlackPawn;
            squareToPiece[53] = Piece.BlackPawn;
            squareToPiece[52] = Piece.BlackPawn;
            squareToPiece[51] = Piece.BlackPawn;
            squareToPiece[50] = Piece.BlackPawn;
            squareToPiece[49] = Piece.BlackPawn;
            squareToPiece[48] = Piece.BlackPawn;

            // initialise piece to bitboard dictionary
            PieceToBitboard[Piece.BlackKing.Index] = Constants.InitialBlackKingBitboard;
            PieceToBitboard[Piece.BlackQueen.Index] = Constants.InitialBlackQueensBitboard;
            PieceToBitboard[Piece.BlackRook.Index] = Constants.InitialBlackRooksBitboard;
            PieceToBitboard[Piece.BlackBishop.Index] = Constants.InitialBlackBishopsBitboard;
            PieceToBitboard[Piece.BlackKnight.Index] = Constants.InitialBlackKnightsBitboard;
            PieceToBitboard[Piece.BlackPawn.Index] = Constants.InitialBlackPawnsBitboard;
            PieceToBitboard[Piece.WhiteKing.Index] = Constants.InitialWhiteKingBitboard;
            PieceToBitboard[Piece.WhiteQueen.Index] = Constants.InitialWhiteQueensBitboard;
            PieceToBitboard[Piece.WhiteRook.Index] = Constants.InitialWhiteRooksBitboard;
            PieceToBitboard[Piece.WhiteBishop.Index] = Constants.InitialWhiteBishopsBitboard;
            PieceToBitboard[Piece.WhiteKnight.Index] = Constants.InitialWhiteKnightsBitboard;
            PieceToBitboard[Piece.WhitePawn.Index] = Constants.InitialWhitePawnsBitboard;
            PieceToBitboard[Piece.None.Index] = 0;

            Initialiser initialiser = new Initialiser();
            _rayAttacks = initialiser.GenerateRayAttacks();

            // initialise rank masks
            _rankMasks = new UInt64[8];
            UInt64 zerothRankMask = 0x00000000000000FF;
            int shiftBy = 0;
            for (int i = 0; i < 8; i++)
            {
                shiftBy = 8 * i;
                _rankMasks[i] = zerothRankMask << shiftBy;
            }

            // set up zobrist hash
            InitialiseZobristHash();
        }