Skip to content

Commit e8f9447

Browse files
Ralph St��ermcostalba
authored andcommitted
Use a formula for chain membership bonus
Passed both short TC: LLR: 2.96 (-2.94,2.94) [-1.50,4.50] Total: 5087 W: 1072 L: 951 D: 3064 And long TC: LLR: 2.95 (-2.94,2.94) [0.00,6.00] Total: 28620 W: 5042 L: 4798 D: 18780 bench: 7995098
1 parent 3cc47ed commit e8f9447

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ int main(int argc, char* argv[]) {
3737
Position::init();
3838
Bitbases::init_kpk();
3939
Search::init();
40+
Pawns::init();
4041
Eval::init();
4142
Threads.init();
4243
TT.set_size(Options["Hash"]);

src/pawns.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

200192
namespace 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.

src/pawns.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ struct Entry {
7373

7474
typedef HashTable<Entry, 16384> Table;
7575

76+
void init();
7677
Entry* probe(const Position& pos, Table& entries);
7778

7879
}

0 commit comments

Comments
 (0)