Cute Chess  0.1
Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
Chess::Zobrist Class Reference

Unsigned 64-bit values for generating zobrist position keys. More...

#include <zobrist.h>

Inheritance diagram for Chess::Zobrist:
Chess::WesternZobrist

Public Member Functions

virtual void initialize (int squareCount, int pieceTypeCount)
 
bool isInitialized () const
 
virtual quint64 piece (const Piece &piece, int square) const
 
virtual quint64 reservePiece (const Piece &piece, int slot) const
 
virtual quint64 side () const
 
 Zobrist (const quint64 *keys=nullptr)
 
virtual ~Zobrist ()
 

Protected Member Functions

const quint64 * keys () const
 
int pieceTypeCount () const
 
int squareCount () const
 

Static Protected Member Functions

static quint64 random64 ()
 

Detailed Description

Unsigned 64-bit values for generating zobrist position keys.

Chess::Board uses zobrist keys to quickly and easily compare two positions for equality. Primary uses for zobrist keys are:

Constructor & Destructor Documentation

Chess::Zobrist::Zobrist ( const quint64 *  keys = nullptr)

Creates a new uninitialized Zobrist object.

Parameters
keysAn array of zobrist keys that can be used instead of the random numbers generated by the Zobrist class.
virtual Chess::Zobrist::~Zobrist ( )
inlinevirtual

Destroys the Zobrist object.

Member Function Documentation

void Chess::Zobrist::initialize ( int  squareCount,
int  pieceTypeCount 
)
virtual

Initializes the zobrist numbers.

Parameters
squareCountThe number of squares the board has, including the invisible "Wall" squares.
pieceTypeCountThe number of piece types the variant has, including the empty "NoPiece" type (type 0).
Note
Subclasses that reimplement this function must call the base implementation.

Reimplemented in Chess::WesternZobrist.

bool Chess::Zobrist::isInitialized ( ) const

Returns true if the keys are initialized.

const quint64 * Chess::Zobrist::keys ( ) const
inlineprotected

Returns the array of zobrist keys.

quint64 Chess::Zobrist::piece ( const Piece piece,
int  square 
) const
virtual

Returns the zobrist value for piece at square.

Reimplemented in Chess::WesternZobrist.

int Chess::Zobrist::pieceTypeCount ( ) const
inlineprotected

Returns the number of piece types the variant has, including the empty "NoPiece" type (type 0).

quint64 Chess::Zobrist::random64 ( )
staticprotected

Returns an unsigned 64-bit pseudo-random number.

quint64 Chess::Zobrist::reservePiece ( const Piece piece,
int  slot 
) const
virtual

Returns the zobrist value for reserve piece piece at slot.

Note
slot is zero-based, so the first piece of type piece is at slot 0.
quint64 Chess::Zobrist::side ( ) const
virtual

Returns the zobrist value for side to move. This value must be in the key on black's turn.

Reimplemented in Chess::WesternZobrist.

int Chess::Zobrist::squareCount ( ) const
inlineprotected

Returns the number of squares the board has, including the invisible "Wall" squares.


The documentation for this class was generated from the following files: