Пример #1
0
        static Zobrist()
        {
            RKiss rnd = (ulong)DateTime.Now.Ticks;

            for (var side = EPlayer.White; side < EPlayer.PlayerNb; ++side)
            {
                for (var pieceType = EPieceType.Pawn; pieceType < EPieceType.PieceTypeNb; ++pieceType)
                {
                    var piece = pieceType.MakePiece(side);
                    for (var square = ESquare.a1; square <= ESquare.h8; square++)
                    {
                        ZobristPst[piece.ToInt(), (int)square] = rnd.Rand();
                    }
                }
            }

            for (var i = 0; i < ZobristCastling.Length; i++)
            {
                ZobristCastling[i] = rnd.Rand();
            }

            for (var i = 0; i < ZobristEpFile.Length; i++)
            {
                ZobristEpFile[i] = rnd.Rand();
            }

            ZobristSide   = rnd.Rand();
            ZobristNoPawn = rnd.Rand();
        }
Пример #2
0
        public void BaseInitializeTest()
        {
            const int tableSizeMb = 8;

            var t = new PawnTable();

            var key       = new RKiss(1234567).Rand();
            var size      = Marshal.SizeOf(typeof(PawnTableEntry));
            var initEntry = new Func <PawnTableEntry>(() => new PawnTableEntry(0));

            t.Initialize(size, tableSizeMb, initEntry);

            var fromTable = t[key];

            fromTable.PassedPawns[0] = BitBoards.Center;

            var reRead = t[key];

            Assert.Equal(reRead.PassedPawns[0], BitBoards.Center);
        }