Tuned null move and history prun... ops, late move reduction :)
[rattatechess.git] / hash.h
blob5708fb62152c5c14d0244afe1ca6fde1f138c60e
1 /***************************************************************************
2 hash.h - Hash related definitions
3 -------------------
4 begin : Sun Nov 28 2007
5 copyright : (C) 2007 by Maurizio Monge
6 email : monge@linuz.sns.it
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #ifndef __HASH_H__
19 #define __HASH_H__
21 #include "utils.h"
23 /* Yes, 96 bits hash keys.
24 the 'index' field is used as index in the hashtable,
25 the 'check' field to check the indexed position.
26 Now, i don't want event to think about possible key collisions :) */
27 class PACKED HashKey
29 public:
30 union
32 uint64_t check;
33 struct {
34 uint32_t check_lo;
35 uint32_t check_hi;
38 uint32_t index;
40 HashKey(){}
41 HashKey(uint64_t c, uint32_t i = 0) :
42 check(c), index(i) {}
43 HashKey(uint32_t ch, uint32_t cl, uint32_t i) :
44 check_lo(cl), check_hi(ch), index(i) {}
46 HashKey operator^(const HashKey& h) const {
47 return HashKey(check ^ h.check, index ^ h.index); }
48 const HashKey& operator^=(const HashKey& h) {
49 check ^= h.check;
50 index ^= h.index;
51 return *this;
53 bool operator==(const HashKey& h) const {
54 return (check == h.check) && (index == h.index); }
55 bool operator!=(const HashKey& h) const {
56 return (check != h.check) || (index != h.index); }
57 bool operator<(const HashKey& h) const {
58 return check<h.check ? true :
59 (check==h.check && index<h.index) ? true :
60 false; }
61 void print() const;
64 /* An entry in the hashtable */
65 class PACKED HashEntry
67 public:
68 /* field to verify the entry against a position */
69 uint64_t check;
70 int16_t depth;
71 uint8_t is_old : 1;
72 uint16_t best_mv : 15;
73 int16_t lo;
74 int16_t up;
76 int16_t lower(){ return lo; }
77 int16_t upper(){ return up; }
80 #endif //__HASH_H__