Cute Chess 0.1
zobrist.h
1/*
2 This file is part of Cute Chess.
3 Copyright (C) 2008-2018 Cute Chess authors
4
5 Cute Chess is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Cute Chess is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef ZOBRIST_H
20#define ZOBRIST_H
21
22#include <QtGlobal>
23
24namespace Chess {
25class Piece;
26
36class LIB_EXPORT Zobrist
37{
38 public:
46 Zobrist(const quint64* keys = nullptr);
48 virtual ~Zobrist() {}
49
51 bool isInitialized() const;
63 virtual void initialize(int squareCount,
64 int pieceTypeCount);
65
70 virtual quint64 side() const;
72 virtual quint64 piece(const Piece& piece, int square) const;
79 virtual quint64 reservePiece(const Piece& piece, int slot) const;
80
81 protected:
86 int squareCount() const;
91 int pieceTypeCount() const;
93 const quint64* keys() const;
94
96 static quint64 random64();
97
98 private:
99 static int random32();
100 static int s_randomSeed;
101
102 bool m_initialized;
103 int m_squareCount;
104 int m_pieceTypeCount;
105 const quint64* m_keys;
106};
107
108inline int Zobrist::squareCount() const
109{
110 return m_squareCount;
111}
112
113inline int Zobrist::pieceTypeCount() const
114{
115 return m_pieceTypeCount;
116}
117
118inline const quint64* Zobrist::keys() const
119{
120 return m_keys;
121}
122
123} //namespace Chess
124#endif // ZOBRIST
A chess piece.
Definition piece.h:41
const quint64 * keys() const
Definition zobrist.h:118
Zobrist(const quint64 *keys=nullptr)
Definition zobrist.cpp:61
int pieceTypeCount() const
Definition zobrist.h:113
virtual ~Zobrist()
Definition zobrist.h:48
int squareCount() const
Definition zobrist.h:108