This time pretty improved the rough-see heuristic.
[rattatechess.git] / hash.h
blobc658da4ac494677b70963f1152a9dc69d47a7433
1 /***************************************************************************
2 hash.h - Hash related definitions
3 -------------------
4 begin : Sun Sep 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;
62 char* to_string(char*) const;
65 /* An entry in the hashtable */
66 class PACKED HashEntry
68 public:
69 /* field to verify the entry against a position */
70 uint64_t check;
71 int16_t depth;
72 uint8_t is_old : 1;
73 uint8_t no_good_moves : 1;
74 uint16_t best_mv : 14;
75 int16_t lo;
76 int16_t up;
78 int16_t lower(){ return lo; }
79 int16_t upper(){ return up; }
82 #endif //__HASH_H__