- // If we are under check it's up to evasions to do the job
- if (is_check())
- return false;
-
- // First pass the move to our opponent doing a null move
- do_null_move(st1);
-
- // Then generate pseudo-legal moves that give check
- last = generate_non_capture_checks(*this, mlist);
- last = generate_captures(*this, last);
-
- // Loop through the moves, and see if one of them gives mate
- Bitboard pinned = pinned_pieces(sideToMove);
- CheckInfo ci(*this);
- for (cur = mlist; cur != last && !mateFound; cur++)
- {
- Move move = cur->move;
- if ( !pl_move_is_legal(move, pinned)
- || !move_is_check(move, ci))
- continue;
-
- do_move(move, st2, ci, true);
-
- if (is_mate())
- mateFound = true;
-
- undo_move(move);
- }
-
- undo_null_move();
- return mateFound;
-}
-
-
-/// Position::init_zobrist() is a static member function which initializes at
-/// startup the various arrays used to compute hash keys.
-
-void Position::init_zobrist() {
-
- int i,j, k;
-
- for (i = 0; i < 2; i++) for (j = 0; j < 8; j++) for (k = 0; k < 64; k++)
- zobrist[i][j][k] = Key(genrand_int64());
-
- for (i = 0; i < 64; i++)
- zobEp[i] = Key(genrand_int64());
-
- for (i = 0; i < 16; i++)
- zobCastle[i] = Key(genrand_int64());
-
- zobSideToMove = Key(genrand_int64());
- zobExclusion = Key(genrand_int64());
-}
+ for (Color c = WHITE; c <= BLACK; c++)
+ for (PieceType pt = PAWN; pt <= KING; pt++)
+ for (Square s = SQ_A1; s <= SQ_H8; s++)
+ zobrist[c][pt][s] = rk.rand<Key>();