예제 #1
0
        public unsafe void TestHashWrong1()
        {
            Zobrist.Init();
            var b = Board.Create();

            Board.SetPiece(b, 10, Board.PIECE_PAWN, Board.COLOR_WHITE);
            Board.SetPiece(b, 34, Board.PIECE_KING, Board.COLOR_BLACK);
            var hash = Zobrist.Calculate(b);

            var hash2 = Zobrist.Read(Zobrist.IndexRead(Board.PIECE_PAWN | Board.COLOR_WHITE), 10);

            hash2 = hash2 ^ Zobrist.Read(Zobrist.IndexRead(Board.PIECE_KING | Board.COLOR_BLACK), 34);

            Assert.AreNotEqual(hash2, hash);
        }
예제 #2
0
        public static void Load()
        {
            for (int i = 0; i < 256; i++)
            {
                Index[i] = Zobrist.IndexRead(i);
            }

            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < 64; j++)
                {
                    Keys[i, j] = Zobrist.Read(i, j);
                }
            }
        }
예제 #3
0
        public unsafe void TestHashOK1()
        {
            Zobrist.Init();
            var b = Board.Create();

            Board.SetPiece(b, 10, Board.PIECE_PAWN, Board.COLOR_WHITE);
            Board.SetPiece(b, 34, Board.PIECE_KING, Board.COLOR_BLACK);
            var hash = Zobrist.Calculate(b);

            var hash2 = Zobrist.Read(Zobrist.IndexRead(Board.PIECE_PAWN | Board.COLOR_WHITE), 10);

            hash2 = hash2 ^ Zobrist.Read(Zobrist.IndexRead(Board.PIECE_KING | Board.COLOR_BLACK), 34);

            hash2 = hash2 ^ Zobrist.Read(Zobrist.ZOBRIST_SIDE, Board.COLOR_WHITE);
            hash2 = hash2 ^ Zobrist.Read(Zobrist.ZOBRIST_CASTLING, Board.CASTLE_BK | Board.CASTLE_BQ | Board.CASTLE_WK | Board.CASTLE_WQ);
            hash2 = hash2 ^ Zobrist.Read(Zobrist.ZOBRIST_ENPASSANT, 0);

            Assert.AreEqual(hash2, hash);
        }
예제 #4
0
 public void TestInit()
 {
     Zobrist.Init();
     var tile23 = Zobrist.Read(Board.BOARD_WHITE | Board.BOARD_PAWNS, 23);
 }