-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathZobrist.cpp
37 lines (30 loc) · 1.04 KB
/
Zobrist.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) 2017 Jason Creighton
// Available under the MIT license, see included LICENSE file for details
#include "Common.hpp"
#include "Zobrist.hpp"
namespace Zobrist {
hash_t SideToMove[2];
hash_t Piece[2][6][64];
hash_t CastlingRights[16];
hash_t EnPassantFile[8];
void Init() {
std::mt19937_64 prng(123456789); // Fixed seed for repeatability
std::uniform_int_distribution<hash_t> dist;
for(int color = 0; color < 2; ++color) { // NOLINT
SideToMove[color] = dist(prng);
}
for(int color = 0; color < 2; ++color) { // NOLINT
for(int piece = 0; piece < 6; ++piece) { // NOLINT
for(int square = 0; square < 64; ++square) { // NOLINT
Piece[color][piece][square] = dist(prng);
}
}
}
for(int i = 0; i < 16; ++i) { // NOLINT
CastlingRights[i] = dist(prng);
}
for(int i = 0; i < 8; ++i) { // NOLINT
EnPassantFile[i] = dist(prng);
}
}
}