-/// init() initializes some tables by formula instead of hard-coding their values
-
-void init() {
-
- const int bonusByFile[] = { 1, 3, 3, 4, 4, 3, 3, 1 };
-
- for (Rank r = RANK_1; r < RANK_8; ++r)
- for (File f = FILE_A; f <= FILE_H; ++f)
- {
- int bonus = r * (r - 1) * (r - 2) + bonusByFile[f] * (r / 2 + 1);
- Connected[f][r] = make_score(bonus, bonus);
- }
+/// init() initializes some tables used by evaluation. Instead of hard-coded
+/// tables, when makes sense, we prefer to calculate them with a formula to
+/// reduce independent parameters and to allow easier tuning and better insight.
+
+void init()
+{
+ static const int Seed[RANK_NB] = { 0, 6, 15, 10, 57, 75, 135, 258 };
+
+ for (int opposed = 0; opposed <= 1; ++opposed)
+ for (int phalanx = 0; phalanx <= 1; ++phalanx)
+ for (Rank r = RANK_2; r < RANK_8; ++r)
+ {
+ int bonus = Seed[r] + (phalanx ? (Seed[r + 1] - Seed[r]) / 2 : 0);
+ Connected[opposed][phalanx][r] = make_score(bonus / 2, bonus >> opposed);
+ }