@@ -11,51 +11,23 @@ fn apply_bonus<const MAX: i32>(entry: &mut i16, bonus: i32) {
1111 * entry += ( bonus - bonus. abs ( ) * ( * entry) as i32 / MAX ) as i16 ;
1212}
1313
14- struct QuietHistoryEntry {
15- factorizer : i16 ,
16- buckets : [ [ i16 ; 2 ] ; 2 ] ,
17- }
18-
19- impl QuietHistoryEntry {
20- const MAX_FACTORIZER : i32 = 1833 ;
21- const MAX_BUCKET : i32 = 6441 ;
22-
23- pub const fn bucket ( & self , threats : Bitboard , mv : Move ) -> i16 {
24- let from_threatened = threats. contains ( mv. from ( ) ) as usize ;
25- let to_threatened = threats. contains ( mv. to ( ) ) as usize ;
26-
27- self . buckets [ from_threatened] [ to_threatened]
28- }
29-
30- pub fn update_factorizer ( & mut self , bonus : i32 ) {
31- let entry = & mut self . factorizer ;
32- apply_bonus :: < { Self :: MAX_FACTORIZER } > ( entry, bonus) ;
33- }
34-
35- pub fn update_bucket ( & mut self , threats : Bitboard , mv : Move , bonus : i32 ) {
36- let from_threatened = threats. contains ( mv. from ( ) ) as usize ;
37- let to_threatened = threats. contains ( mv. to ( ) ) as usize ;
38-
39- let entry = & mut self . buckets [ from_threatened] [ to_threatened] ;
40- apply_bonus :: < { Self :: MAX_BUCKET } > ( entry, bonus) ;
41- }
42- }
43-
4414pub struct QuietHistory {
45- entries : Box < [ FromToHistory < QuietHistoryEntry > ; 2 ] > ,
15+ // [side_to_move][from_threatened][to_threatened][from][to]
16+ entries : Box < [ [ [ FromToHistory < i16 > ; 2 ] ; 2 ] ; 2 ] > ,
4617}
4718
4819impl QuietHistory {
20+ const MAX_HISTORY : i32 = 8192 ;
21+
4922 pub fn get ( & self , threats : Bitboard , stm : Color , mv : Move ) -> i32 {
50- let entry = & self . entries [ stm] [ mv. from ( ) ] [ mv. to ( ) ] ;
51- ( entry . factorizer + entry . bucket ( threats , mv ) ) as i32
23+ self . entries [ stm] [ threats . contains ( mv. from ( ) ) as usize ] [ threats . contains ( mv. to ( ) ) as usize ] [ mv . from ( ) ] [ mv . to ( ) ]
24+ as i32
5225 }
5326
5427 pub fn update ( & mut self , threats : Bitboard , stm : Color , mv : Move , bonus : i32 ) {
55- let entry = & mut self . entries [ stm] [ mv. from ( ) ] [ mv. to ( ) ] ;
56-
57- entry. update_factorizer ( bonus) ;
58- entry. update_bucket ( threats, mv, bonus) ;
28+ let entry = & mut self . entries [ stm] [ threats. contains ( mv. from ( ) ) as usize ] [ threats. contains ( mv. to ( ) ) as usize ]
29+ [ mv. from ( ) ] [ mv. to ( ) ] ;
30+ apply_bonus :: < { Self :: MAX_HISTORY } > ( entry, bonus) ;
5931 }
6032}
6133
0 commit comments