Belofte version 2.1.8
A promising chess program using the UCI or Winboard interface
bel_hash.cpp
Go to the documentation of this file.
1/*---------------------------------------------------------------------+
2 * File: bel_hash.cpp
3 * Project: part of belofte - A Promising Chess Program
4 * Author: yves
5 * SPDX-License-Identifier: GPL-2.0-only
6+----------------------------------------------------------------------*/
7
8#include "belofte.h"
9
11
13 : m_isFullInit{false}
14{
15}
16
20
22{
23 if (!m_isFullInit) {
24 // piece keys, special moves are in piece empty location
25 for (int i = 0; i < tPiece::P_SIZE; i++) {
26 for (case_t iCase = 0; iCase < 64; iCase++) {
27 hashmultiplexer[i][iCase] = getRandom();
28 }
29 }
30
31 m_isFullInit = true;
32 }
33}
34
35/** return hashkey, as rand is giving by definition
36 * result in between 0 and 32768, do not take the risk of zero bits
37 * and shift possibly getting bits falling off
38 * specification is only giving 15 significant bits, as we do not need
39 * upper bits, take this into account
40 */
41hashkey_t bel_hash::getRandom(void) {
42 hashkey_t r = (rand() & 0x8FFF); // ensure same result independent of platform
43 r = (r << 15) + (rand() & 0x8FFF);
44 r = (r << 15) + (rand() & 0x8FFF);
45 r = (r << 15) + (rand() & 0x8FFF);
46 r = r & 0x00FFFFFFFFFFFFFFLL; // strip off higher 8 bits
47 return r;
48}
49
50// eof
hashkey_t hashmultiplexer[tPiece::P_SIZE][64]
Definition bel_hash.cpp:10
unsigned long long hashkey_t
Definition bel_hash.h:12
hashkey_t hashmultiplexer[tPiece::P_SIZE][64]
Definition bel_hash.cpp:10
This is the main include file, needs to be included before any other include.
uint8_t case_t
Definition belofte.h:106
void delayed_ctor()
Definition bel_hash.cpp:21
@ P_SIZE
Definition piece.h:41