Skip to content

Commit 480682b

Browse files
mcostalbazamar
authored andcommitted
Document why initing eval tables
Instead of hard-code the weights in a big table, we prefer to calculate them out of few parameters at startup. This allows to keep low the number of independent parameters and hence is good for tuning and for a better insight in the meaning of the numbers. No functional change.
1 parent 89d9db2 commit 480682b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/pawns.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,24 @@ namespace {
194194

195195
namespace Pawns {
196196

197+
/// init() initializes some tables used by evaluation. Instead of hard-coded
198+
/// tables, when makes sense, we prefer to calculate them with a formula to
199+
/// reduce independent parameters and to allow easier tuning and better insight.
200+
197201
void init()
198202
{
199-
const int c[RANK_NB] = {0, 6, 15, 10, 57, 75, 135, 258};
203+
static const int Seed[RANK_NB] = { 0, 6, 15, 10, 57, 75, 135, 258 };
200204

201-
for (Rank r = RANK_2; r <= RANK_7; ++r)
202-
for (int opposed = false; opposed <= true; ++opposed)
203-
for (int phalanx = false; phalanx <= true; ++phalanx)
205+
for (int opposed = 0; opposed <= 1; ++opposed)
206+
for (int phalanx = 0; phalanx <= 1; ++phalanx)
207+
for (Rank r = RANK_2; r < RANK_8; ++r)
204208
{
205-
int bonus = c[r] + (phalanx ? (c[r + 1] - c[r]) / 2 : 0);
209+
int bonus = Seed[r] + (phalanx ? (Seed[r + 1] - Seed[r]) / 2 : 0);
206210
Connected[opposed][phalanx][r] = make_score(bonus / 2, bonus >> opposed);
207211
}
208212
}
209213

214+
210215
/// probe() takes a position as input, computes a Entry object, and returns a
211216
/// pointer to it. The result is also stored in a hash table, so we don't have
212217
/// to recompute everything when the same pawn structure occurs again.

0 commit comments

Comments
 (0)