Thank you all for the answers  
 
Right after I posted about my king attack implementation yesterday, I noticed that the Data.king_attack_value counters only counted the attacking piece instead of the number of squares it attacked... When I fixed this, I got the following results against the old king safety implementation:
Code: Select all
Score of Lokidev vs master: 431 - 348 - 447  [0.534] 1226
...      Lokidev playing White: 232 - 153 - 228  [0.564] 613
...      Lokidev playing Black: 199 - 195 - 219  [0.503] 613
...      White vs Black: 427 - 352 - 447  [0.531] 1226
Elo difference: 23.6 +/- 15.5, LOS: 99.9 %, DrawRatio: 36.5 %
SPRT: llr 2.97 (100.9%), lbound -2.94, ubound 2.94 - H1 was accepted
I think that this is enough to move onto other parts of king safety (weak squares, defenders etc..).
I already have code for scoring the king's pawn shield, but this isn't included in safety calculation (it is just a normal, linear term) and I think it should be. My reasoning is that a bad pawn shield should receive an extra penalty if the king is also being attacked at the same time.
Additionally, I will try implementing some code for storming enemy pawns. I tried to do this yesterday, but it didn't give good results even though I scored them exactly the same as the pawn shield (with other values of course..).
No4b wrote: ↑Thu Aug 12, 2021 12:52 am
Various experiments showed to me that for Drofa best scheme of safety is 
Code: Select all
score += gS(std::max(0, attackScore), 0);
 - ie. all score goes in OPENING phase of the tapered evaluation.
 
I just started a test where I don't include endgame king safety in the evaluation  

 I suppose you do this in order to not risk discouraging the king from advancing? 
I still use the middlegame scaling:
Code: Select all
mg_score += -1 * safety * std::max(safety, 0) / 256;
 
I just looked through the code in your link. The idea of using a sigmoid function for attack scoring reminded me of the safety table/attack units method proposed on the 
CPW. The tables there also rise in a logistic fashion it seems.
I tried using an attack table/sigmoidal approach before, but it didn't really work, and I think there are two reasons for that: 1) I only scored the attacks, which means that I rarely got big safety scores even though a large attack was happening, and 2) Due to my current tuner being an SPSA one, it was hard to tune the table since the scaling made perturbations of the values less significant (smaller gradients).
I still have the second problem, which is why I am trying to implement a new tuner.
Thanks for the link. I tried this approach, with a safety table, but saw only small gains. I think, however, that that's because I didn't implement it properly.
If I get more problems with the Toga approach, I will take a shot at this one again  
