The training set seemed a bit small, probably also because the positions were not independent. So I generated a new training set from 10k games, sampled every 9 half-moves (instead of every 3). This gave me some 945k quiet positions.
I have added mobility to the evaluation: a bonus per non-capture for each piece type, a bonus for attacking something independent of piece type, and a bonus for protecting higher-valued and one for equal-valued pieces. (Because a Korean player suggested to me this could be important.) I did not want to diversify that by piece type, (although the evaluation is written such that it does; it is just that the table is initialized with many identical values in it), because the tuner is still quite slow if I tune too many variables. For the same reason my PST are also generated from just a few free parameters, rather than havein 90 (well, 50, because of symmetry) independent values for each square. This gave me 59 parameters, which I did optimize. This also ncludes a non-linear distortion of the total score, to create the proper trading incentive. I did a long optimization run on that, and the piece values that came out look very reasonable.
Then I tried to tune complete PST (50 parameters for R, C, H and E each, 35 for P), while keeping the other 59 parameters constant. (Those used to determine the original PST would no longer be used anyway.) First I tuned the PST for each type in isolation. Since I started from the previously optimized parameter set, this of course lowered the MSE a bit. This gave very sensible results: Pawns get worth vastly more when they approach the Palace; when they enter it on d7 or e7 the PST value even saturates at 127 (I use signed char). Same for Horses and Elephants: squares where these attack two Palace squares get the highest value, in the corners of your own back rank you get very large penalty, etc. So this seems to work.
When I combined all individually optimized PST, the MSE was significantly worse than with the parametrized tables I started from, though. This was a bit unexpected. It seems there is a correlation between different pieces for being on good squares. Probably because a player that is winning can force all his pieces to good squares. (Or perhaps that is why he is winning.) So if I only optimize the Elephant PST, the Elephant starts to take credit for the Rook also being on above-average good squares when the Elephant is. And vice versa. So when I then use both tables, bot E and R get overweighted. I really must tune them all at once.
Fortunately tuning PST values is not as difficult as some of the others: each square is only rarely occupied, and thus contributes little. And the values are small enough and close enough to each other that they don't really expose the non-linearity of the sigmoid that translates scores to expected outcome. So I am doing an optimization run for all 235 PST values. And indeed the MSE quicly dropped to a value below that of the best MSE I got when optimizing a single PST.
Code: Select all
// Pawn, King, Advisor
-3, -3, -3,-19,-19,-19, 21, 20, 40, 44, 67, 44, 40, 20, 21,
-50, 7,-50, -3,-18, -3, 39, 45, 32, 36, 58, 36, 32, 45, 39,
-98,-98,-98, 7, 7, 7, 12, 17, 9,101, 44,101, 9, 17, 12,
-33,-18, 9, 13, 41, 13, 9,-18,-33, 5, 26, 55, 65, 38, 65, 55, 26, 5,
-25,-30, 0, 15, 43, 15, 0,-30,-25, 7, -6, 21, 24, 33, 24, 21, -6, 7,
7, -6, 21, 24, 33, 24, 21, -6, 7, -25,-30, 0, 15, 43, 15, 0,-30,-25,
5, 26, 55, 65, 38, 65, 55, 26, 5, -33,-18, 9, 13, 41, 13, 9,-18,-33,
12, 17, 9,101, 44,101, 9, 17, 12, 7, 7, 7,-98,-98,-98,
39, 45, 32, 36, 58, 36, 32, 45, 39, -3,-18, -3,-50, 7,-50,
21, 20, 40, 44, 67, 44, 40, 20, 21, -19,-19,-19, -3, -3, -3,
// Elephant
-10,-12, -9, 1, 28, 1, -9,-12,-10, 22, 12, 6, 22, 24, 22, 6, 12, 22,
-16,-23,-28,-20, 29,-20,-28,-23,-16, 12, 16, 10, 20, 15, 20, 10, 16, 12,
-12,-15, -6, 33, 22, 33, -6,-15,-12, 4, 5, 11, 10, 17, 10, 11, 5, 4,
-23,-26, 1, 13, 12, 13, 1,-26,-23, 0, 21, 10, 26, 2, 26, 10, 21, 0,
-6, -5, 21, -2, 5, -2, 21, -5, -6, 17, 38, -9, -7, 18, -7, -9, 38, 17,
17, 38, -9, -7, 18, -7, -9, 38, 17, -6, -5, 21, -2, 5, -2, 21, -5, -6,
0, 21, 10, 26, 2, 26, 10, 21, 0, -23,-26, 1, 13, 12, 13, 1,-26,-23,
4, 5, 11, 10, 17, 10, 11, 5, 4, -12,-15, -6, 33, 22, 33, -6,-15,-12,
12, 16, 10, 20, 15, 20, 10, 16, 12, -16,-23,-28,-20, 29,-20,-28,-23,-16,
22, 12, 6, 22, 24, 22, 6, 12, 22, -10,-12, -9, 1, 28, 1, -9,-12,-10,
// Horse
-44,-45,-40,-41, -5,-41,-40,-45,-44, 10, 2, 5, 25, 47, 25, 5, 2, 10,
-46,-40,-25,-29, 4,-29,-25,-40,-46, 17, 15, 18, 31, 30, 31, 18, 15, 17,
-49,-38, 7, 4, -2, 4, 7,-38,-49, 7, 9, 35, 39, 37, 39, 35, 9, 7,
-20,-14,-14, -8, 9, -8,-14,-14,-20, 0, 24, 22, 49, 32, 49, 22, 24, 0,
-18, 24, 8, 11, 12, 11, 8, 24,-18, 9, 7, 34, 43, 31, 43, 34, 7, 9,
9, 7, 34, 43, 31, 43, 34, 7, 9, -18, 24, 8, 11, 12, 11, 8, 24,-18,
0, 24, 22, 49, 32, 49, 22, 24, 0, -20,-14,-14, -8, 9, -8,-14,-14,-20,
7, 9, 35, 39, 37, 39, 35, 9, 7, -49,-38, 7, 4, -2, 4, 7,-38,-49,
17, 15, 18, 31, 30, 31, 18, 15, 17, -46,-40,-25,-29, 4,-29,-25,-40,-46,
10, 2, 5, 25, 47, 25, 5, 2, 10, -44,-45,-40,-41, -5,-41,-40,-45,-44,
// Cannon
1,-23,-11, 95, 79, 95,-11,-23, 1, -42,-28,-28, 7, 51, 7,-28,-28,-42,
-2, -3, 0, 50, 44, 50, 0, -3, -2, -30,-24,-41,-27, 51,-27,-41,-24,-30,
-11, -8, 4, 32,116, 32, 4, -8,-11, -19, -4, -5, 33, 61, 33, -5, -4,-19,
-12,-11,-23, 34, 40, 34,-23,-11,-12, -8,-20,-15, 19, 62, 19,-15,-20, -8,
-25,-18,-14, 21, 72, 21,-14,-18,-25, -2, 3,-10, 8, 61, 8,-10, 3, -2,
-2, 3,-10, 8, 61, 8,-10, 3, -2, -25,-18,-14, 21, 72, 21,-14,-18,-25,
-8,-20,-15, 19, 62, 19,-15,-20, -8, -12,-11,-23, 34, 40, 34,-23,-11,-12,
-19, -4, -5, 33, 61, 33, -5, -4,-19, -11, -8, 4, 32,116, 32, 4, -8,-11,
-30,-24,-41,-27, 51,-27,-41,-24,-30, -2, -3, 0, 50, 44, 50, 0, -3, -2,
-42,-28,-28, 7, 51, 7,-28,-28,-42, 1,-23,-11, 95, 79, 95,-11,-23, 1,
// Rook
-55,-50,-25, 32, 68, 32,-25,-50,-55, 27, 25, 35, 51, 38, 51, 35, 25, 27,
-48,-45,-16, 27, 60, 27,-16,-45,-48, -26,-13,-12, 1, 37, 1,-12,-13,-26,
-27, -9, -2, 9, 63, 9, -2, -9,-27, 17, 33, 22, 2, 43, 2, 22, 33, 17,
-34,-21,-28, -8, 35, -8,-28,-21,-34, -13,-13, 10, 2, 35, 2, 10,-13,-13,
-36, -6,-18, 11, 20, 11,-18, -6,-36, -23,-29,-39,-20, 34,-20,-39,-29,-23,
-23,-29,-39,-20, 34,-20,-39,-29,-23, -36, -6,-18, 11, 20, 11,-18, -6,-36,
-13,-13, 10, 2, 35, 2, 10,-13,-13, -34,-21,-28, -8, 35, -8,-28,-21,-34,
17, 33, 22, 2, 43, 2, 22, 33, 17, -27, -9, -2, 9, 63, 9, -2, -9,-27,
-26,-13,-12, 1, 37, 1,-12,-13,-26, -48,-45,-16, 27, 60, 27,-16,-45,-48,
27, 25, 35, 51, 38, 51, 35, 25, 27, -55,-50,-25, 32, 68, 32,-25,-50,-55,
//a b c d e f g h i a b c d e f g h i
We see for instance that the Elephant gets a high bonus for being on b5/h5.