Add Game::is_dangerous() for Futility Pruning
[purplehaze.git] / src / zobrist.cpp
blob23a179ff046f455fd4d347fd3acd70754d55dd0a
1 /* Copyright (C) 2007-2011 Vincent Ollivier
3 * Purple Haze is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * Purple Haze is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "zobrist.h"
19 Zobrist::Zobrist()
21 generator.seed(); // Use Mersenne twister's default seed
23 side_to_move = gen_hash();
24 for (int c = 0; c < 2; ++c) {
25 for (int t = 0; t < 7; ++t) {
26 for (int s = 0; s < BOARD_SIZE; ++s) {
27 pieces_positions[c][t][s] = gen_hash();
31 for (int i = 0; i < 4; ++i) {
32 castle_rights[i] = gen_hash();
34 for (int i = 0; i < BOARD_SIZE; ++i) {
35 en_passants[i] = gen_hash();
39 // Generate a random Hash
40 Hash Zobrist::gen_hash()
42 Hash h = generator();
43 return h;