Skip to content

Commit 9b87009

Browse files
committed
change tt strategy to always replace
Rank Name Elo +/- Games Wins Losses Draws Points Score Draw 0 dev -2 6 9000 2723 2785 3492 4469.0 49.7% 38.8% 1 Marvin-6.2 68 9 3000 1076 495 1429 1790.5 59.7% 47.6% 2 Stash-35.0 -11 10 3000 969 1061 970 1454.0 48.5% 32.3% 3 Avalanche-2.1.0 -50 10 3000 740 1167 1093 1286.5 42.9% 36.4%
1 parent 760608b commit 9b87009

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

lib/search/transposition.rs

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ impl Transposition {
102102
impl Binary for Transposition {
103103
type Bits = Bits<u64, 37>;
104104

105+
#[inline(always)]
105106
fn encode(&self) -> Self::Bits {
106107
let mut bits = Bits::default();
107108
bits.push(self.depth.encode());
@@ -111,6 +112,7 @@ impl Binary for Transposition {
111112
bits
112113
}
113114

115+
#[inline(always)]
114116
fn decode(mut bits: Self::Bits) -> Self {
115117
Transposition {
116118
best: Binary::decode(bits.pop()),
@@ -130,13 +132,15 @@ struct SignedTransposition(Signature, <Transposition as Binary>::Bits);
130132
impl Binary for SignedTransposition {
131133
type Bits = Bits<u64, 64>;
132134

135+
#[inline(always)]
133136
fn encode(&self) -> Self::Bits {
134137
let mut bits = Bits::default();
135138
bits.push(self.1);
136139
bits.push(self.0);
137140
bits
138141
}
139142

143+
#[inline(always)]
140144
fn decode(mut bits: Self::Bits) -> Self {
141145
SignedTransposition(bits.pop(), bits.pop())
142146
}
@@ -214,7 +218,7 @@ impl TranspositionTable {
214218
if self.capacity() > 0 {
215219
let sig = self.signature_of(key);
216220
let bits = Some(SignedTransposition(sig, tpos.encode())).encode();
217-
self.cache[self.index_of(key)].fetch_max(bits.get(), Ordering::Relaxed);
221+
self.cache[self.index_of(key)].store(bits.get(), Ordering::Relaxed);
218222
}
219223
}
220224
}
@@ -326,31 +330,14 @@ mod tests {
326330
}
327331

328332
#[proptest]
329-
fn set_keeps_transposition_with_greater_depth(
330-
#[by_ref] mut tt: TranspositionTable,
331-
t: Transposition,
332-
#[filter(#t.depth() != #u.depth())] u: Transposition,
333-
k: Zobrist,
334-
) {
335-
let st = Some(SignedTransposition(tt.signature_of(k), t.encode()));
336-
*tt.cache[tt.index_of(k)].get_mut() = st.encode().get();
337-
tt.set(k, u);
338-
339-
if t.depth() > u.depth() {
340-
assert_eq!(tt.get(k), Some(t));
341-
} else {
342-
assert_eq!(tt.get(k), Some(u));
343-
}
344-
}
345-
346-
#[proptest]
347-
fn set_ignores_the_signature_mismatch(
333+
fn set_replaces_transposition_if_one_exists(
348334
#[by_ref] mut tt: TranspositionTable,
335+
s: Signature,
349336
t: Transposition,
350-
#[filter(#u.depth() > #t.depth())] u: Transposition,
337+
u: Transposition,
351338
k: Zobrist,
352339
) {
353-
let st = Some(SignedTransposition(!tt.signature_of(k), t.encode()));
340+
let st = Some(SignedTransposition(s, t.encode()));
354341
*tt.cache[tt.index_of(k)].get_mut() = st.encode().get();
355342
tt.set(k, u);
356343
assert_eq!(tt.get(k), Some(u));
@@ -362,7 +349,7 @@ mod tests {
362349
t: Transposition,
363350
k: Zobrist,
364351
) {
365-
*tt.cache[tt.index_of(k)].get_mut() = 0;
352+
*tt.cache[tt.index_of(k)].get_mut() = None::<SignedTransposition>.encode().get();
366353
tt.set(k, t);
367354
assert_eq!(tt.get(k), Some(t));
368355
}

0 commit comments

Comments
 (0)