- // init_safety() initizes the king safety evaluation, based on UCI
- // parameters. It is called from read_weights().
-
- void init_safety() {
-
- const Value MaxSlope = Value(30);
- const Value Peak = Value(1280);
- Value t[100];
-
- // First setup the base table
- for (int i = 0; i < 100; i++)
- {
- t[i] = Value(int(0.4 * i * i));
-
- if (i > 0)
- t[i] = std::min(t[i], t[i - 1] + MaxSlope);
-
- t[i] = std::min(t[i], Peak);
- }
-
- // Then apply the weights and get the final KingDangerTable[] array
- for (Color c = WHITE; c <= BLACK; c++)
- for (int i = 0; i < 100; i++)
- KingDangerTable[c][i] = apply_weight(make_score(t[i], 0), Weights[KingDangerUs + c]);
- }
-
-