/// <summary> /// Initializes chess with the custom fen. /// </summary> public void InitializeChess(string FEN) { Magics.Init(); //Initialize magics ;) Zobrist.Init(); //Initiliaze zobrist MvvLva.Init(); //Initialize chess board = new Board(FEN); Moves = new SMove[256]; search = new AI(board); OnTurnSwitched(64, 64); //Call it on start }
public unsafe void TestHashBoardSet() { 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); Board.SetPiece(b, 4, Board.PIECE_KING, Board.COLOR_WHITE); Board.SetPiece(b, 12, Board.PIECE_QUEEN, Board.COLOR_WHITE); Board.SetPiece(b, 61, Board.PIECE_ROOK, Board.COLOR_BLACK); var hash = Zobrist.Calculate(b); Assert.AreEqual(hash, b->Hash); }
public Board() { WhitePawns = SquareFlag.A2 | SquareFlag.B2 | SquareFlag.C2 | SquareFlag.D2 | SquareFlag.E2 | SquareFlag.F2 | SquareFlag.G2 | SquareFlag.H2; WhiteRooks = SquareFlag.A1 | SquareFlag.H1; WhiteKnights = SquareFlag.B1 | SquareFlag.G1; WhiteBishops = SquareFlag.C1 | SquareFlag.F1; WhiteQueens = SquareFlag.D1; WhiteKing = SquareFlag.E1; BlackPawns = SquareFlag.A7 | SquareFlag.B7 | SquareFlag.C7 | SquareFlag.D7 | SquareFlag.E7 | SquareFlag.F7 | SquareFlag.G7 | SquareFlag.H7; BlackRooks = SquareFlag.A8 | SquareFlag.H8; BlackKnights = SquareFlag.B8 | SquareFlag.G8; BlackBishops = SquareFlag.C8 | SquareFlag.F8; BlackQueens = SquareFlag.D8; BlackKing = SquareFlag.E8; keyGen.Init(); Key = keyGen.Hash(this, Colour.White); history.Push(new BoardStateInfo(Key, 0, DefaultState, 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); }
public unsafe void TestHashBoardUnset() { Zobrist.Init(); var b = Board.Create(); Board.Init(b, 1); Board.ClearPiece(b, 10); Board.ClearPiece(b, 2); Board.ClearPiece(b, 62); Board.ClearPiece(b, 57); Board.ClearPiece(b, 53); Board.ClearPiece(b, 30); // empty area var hash = Zobrist.Calculate(b); Assert.AreEqual(hash, b->Hash); }
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); }
public void TestInit() { Zobrist.Init(); var tile23 = Zobrist.Read(Board.BOARD_WHITE | Board.BOARD_PAWNS, 23); }
public KeyGeneratorFixture() { KeyGenerator = new Zobrist(); KeyGenerator.Init(); }
public static void Init() { Zobrist.Init(); Bitboard.Init(); }