1 /* Copyright (C) 2007-2011 Vincent Ollivier
3 * Purple Haze is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * Purple Haze is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "hashtable.h"
30 short value
; // 2 bytes / 16 bits used
31 Move best_move
; // 2 bytes / 16 bits used
32 unsigned char depth
; // 1 byte / 8 bits used: depth < 256
33 Bound bound
; // 1 byte / 2 bits used
36 Transposition(int v
, Bound b
, int d
, Move bm
)
37 : value(v
), best_move(bm
), depth(d
),
40 : value(0), best_move(Move()), depth(0),
43 int get_value() const { return value
; };
44 int get_depth() const { return depth
; };
45 Bound
get_bound() const { return bound
; };
46 Move
get_best_move() const { return best_move
; };
48 bool is_empty() const {
51 bound
== UNDEF_BOUND
&&
55 bool operator==(const Transposition
& other
) const {
56 return this->value
== other
.value
&&
57 this->depth
== other
.depth
&&
58 this->bound
== other
.bound
&&
59 this->best_move
== other
.best_move
;
61 bool operator!=(const Transposition
& other
) const {
62 return !(*this == other
);
65 std::string
to_string() const;
68 class Transpositions
: public HashTable
<Transposition
>
71 static const Transposition NULL_ENTRY
;
74 Transpositions(int n
= TT_SIZE
) : HashTable
<Transposition
>(n
) {}
76 void save(Hash h
, int v
, Bound b
, int d
, Move bm
) {
77 HashTable
<Transposition
>::save(h
, Transposition(v
, b
, d
, bm
));