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