Chess Engine
C++ chess engine with movegen, bitboards, and Arduino-friendly docs
Loading...
Searching...
No Matches
hash_keys.cpp File Reference
#include <cstdio>
#include "../defs.h"
#include "setup.h"
Include dependency graph for hash_keys.cpp:

Go to the source code of this file.

Functions

U64 generatePositionKeys (const S_BOARD *board)
 Generates a Zobrist hash key for the given board position.

Function Documentation

◆ generatePositionKeys()

U64 generatePositionKeys ( const S_BOARD * pos)

Generates a Zobrist hash key for the given board position.

The key uniquely (with very high probability) represents:

  • Pieces on all squares
  • Side to move
  • Castling rights
  • En passant square (if any)
Parameters
posPointer to the current board state.
Returns
64-bit Zobrist position key.

Definition at line 5 of file hash_keys.cpp.

References ASSERT, bK, BRD_SQ_NUM, S_BOARD::castlePerm, EMPTY, S_BOARD::enPas, NO_SQ, OFFBOARD, S_BOARD::pieces, RANK_3, RANK_6, rankIndex120, S_BOARD::side, SqOnBoard(), WHITE, wP, zobristCastleKeys, zobristPieceKeys, and zobristSideKey.

Referenced by isBoardStateValid(), loadFEN(), and mirrorBoardPosition().

Here is the call graph for this function:
Here is the caller graph for this function: