@@ -51,16 +51,8 @@ namespace {
5151 { S (20 , 28 ), S (29 , 31 ), S (33 , 31 ), S (33 , 31 ),
5252 S (33 , 31 ), S (33 , 31 ), S (29 , 31 ), S (20 , 28 ) }};
5353
54- // Pawn chain membership bonus by file
55- const Score ChainMember[FILE_NB][RANK_NB] = {
56- { S (0 , 0 ), S (14 , 0 ), S (16 , 4 ), S (18 , 9 ), S (28 , 28 ), S (52 , 104 ), S (118 , 236 ) },
57- { S (0 , 0 ), S (16 , 0 ), S (18 , 5 ), S (20 , 10 ), S (30 , 30 ), S (54 , 108 ), S (120 , 240 ) },
58- { S (0 , 0 ), S (16 , 0 ), S (18 , 5 ), S (20 , 10 ), S (30 , 30 ), S (54 , 108 ), S (120 , 240 ) },
59- { S (0 , 0 ), S (17 , 0 ), S (19 , 6 ), S (22 , 11 ), S (33 , 33 ), S (59 , 118 ), S (127 , 254 ) },
60- { S (0 , 0 ), S (17 , 0 ), S (19 , 6 ), S (22 , 11 ), S (33 , 33 ), S (59 , 118 ), S (127 , 254 ) },
61- { S (0 , 0 ), S (16 , 0 ), S (18 , 5 ), S (20 , 10 ), S (30 , 30 ), S (54 , 108 ), S (120 , 240 ) },
62- { S (0 , 0 ), S (16 , 0 ), S (18 , 5 ), S (20 , 10 ), S (30 , 30 ), S (54 , 108 ), S (120 , 240 ) },
63- { S (0 , 0 ), S (14 , 0 ), S (16 , 4 ), S (18 , 9 ), S (28 , 28 ), S (52 , 104 ), S (118 , 236 ) }};
54+ // Pawn chain membership bonus by file and rank (initialized by formula)
55+ Score ChainMember[FILE_NB][RANK_NB];
6456
6557 // Candidate passed pawn bonus by rank
6658 const Score CandidatePassed[RANK_NB] = {
@@ -199,6 +191,22 @@ namespace {
199191
200192namespace Pawns {
201193
194+ // / init() initializes some tables by formula instead of hard-code their values
195+
196+ void init () {
197+
198+ const int chainByFile[8 ] = { 1 , 3 , 3 , 4 , 4 , 3 , 3 , 1 };
199+ int bonus;
200+
201+ for (Rank r = RANK_1; r < RANK_8; ++r)
202+ for (File f = FILE_A; f <= FILE_H; ++f)
203+ {
204+ bonus = r * (r-1 ) * (r-2 ) + chainByFile[f] * (r/2 + 1 );
205+ ChainMember[f][r] = make_score (bonus, bonus);
206+ }
207+ }
208+
209+
202210// / probe() takes a position object as input, computes a Entry object, and returns
203211// / a pointer to it. The result is also stored in a hash table, so we don't have
204212// / to recompute everything when the same pawn structure occurs again.
0 commit comments