@@ -102,6 +102,7 @@ impl Transposition {
102102impl 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);
130132impl 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