1 /* Copyright (C) 2007-2012 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"
29 int16_t value_
; // 2 bytes / 16 bits used
30 Move best_move_
; // 2 bytes / 16 bits used
31 unsigned char depth_
; // 1 byte / 8 bits used (depth < 256)
32 Bound bound_
; // 1 byte / 2 bits used
35 Transposition(int v
, Bound b
, int d
, Move bm
)
36 : value_(v
), best_move_(bm
), depth_(d
),
39 : value_(0), best_move_(Move()), depth_(0),
40 bound_(UNDEF_BOUND
) {}
51 Move
best_move() const {
55 bool is_empty() const {
58 bound_
== UNDEF_BOUND
&&
62 bool operator==(const Transposition
& other
) const {
63 return this->value_
== other
.value_
&&
64 this->depth_
== other
.depth_
&&
65 this->bound_
== other
.bound_
&&
66 this->best_move_
== other
.best_move_
;
68 bool operator!=(const Transposition
& other
) const {
69 return !(*this == other
);
72 std::string
to_string() const;
75 class Transpositions
: public HashTable
<Transposition
>
78 static const Transposition NULL_ENTRY
;
81 Transpositions(int n
= TT_SIZE
) : HashTable
<Transposition
>(n
) {}
83 void save(Hash h
, int v
, Bound b
, int d
, Move bm
) {
84 HashTable
<Transposition
>::save(h
, Transposition(v
, b
, d
, bm
));