Belofte version 2.1.9
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{
14 if (!m_isFullInit) {
15 // piece keys, special moves are in piece empty location
16 for (int i = 0; i < tPiece::P_SIZE; ++i) {
17 for (case_t iCase = 0; iCase < 64; ++iCase) {
18 hashmultiplexer[i][iCase] = getRandom();
19 }
20 }
21
22 m_isFullInit = true;
23 }
24}
25
26/** return hashkey, as rand is giving by definition
27 * result in between 0 and 32768, do not take the risk of zero bits
28 * and shift possibly getting bits falling off
29 * specification is only giving 15 significant bits, as we do not need
30 * upper bits, take this into account
31 */
32hashkey_t bel_hash::getRandom(void) {
33 hashkey_t r = (rand() & 0x8FFF); // ensure same result independent of platform
34 r = (r << 15) + (rand() & 0x8FFF);
35 r = (r << 15) + (rand() & 0x8FFF);
36 r = (r << 15) + (rand() & 0x8FFF);
37 r = r & 0x00FFFFFFFFFFFFFFLL; // strip off higher 8 bits
38 return r;
39}
40
41// eof
hashkey_t hashmultiplexer[tPiece::P_SIZE][64]
Definition bel_hash.cpp:10
uint64_t 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:96
void delayed_ctor()
Definition bel_hash.cpp:12
@ P_SIZE
Definition piece.h:41