-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
zobrist.cpp
executable file
·53 lines (44 loc) · 1.02 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "zobrist.h"
#include <random>
namespace Napoleon
{
ZobristKey Zobrist::Piece[2][6][64];
ZobristKey Zobrist::Castling[16];
ZobristKey Zobrist::Enpassant[8];
ZobristKey Zobrist::Color;
class RandomGenerator
{
public:
RandomGenerator() :gen(std::mt19937_64::default_seed) { }
unsigned long long Next()
{
return dist(gen);
}
private:
std::uniform_int_distribution<unsigned long long> dist;
std::mt19937_64 gen;
};
void Zobrist::Init()
{
RandomGenerator gen;
for (int i=0; i< 2; i++)
{
for (int j=0; j<6; j++)
{
for (int k=0; k<64; k++)
{
Piece[i][j][k] = gen.Next();
}
}
}
Color = gen.Next();
for (int i=0; i<16; i++)
{
Castling[i] = gen.Next();
}
for (int i=0; i<8; i++)
{
Enpassant[i] = gen.Next();
}
}
}