Evaluating piece value

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Jon12345
Posts: 80
Joined: Tue May 11, 2010 6:18 pm

Evaluating piece value

Post by Jon12345 »

Are there any good algos out there that evaluate a piece value? e.g. Knight located on a4...what is its value?
Jon
amanjpro
Posts: 883
Joined: Sat Mar 13, 2021 1:47 am
Full name: Amanj Sherwany

Re: Evaluating piece value

Post by amanjpro »

PSQT combined with Texel tuning?
User avatar
hgm
Posts: 27829
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Evaluating piece value

Post by hgm »

I had a very poor experience with that in my Janggi engine, although this might be peculiar to Janggi. The version with a Texel-tuned PST basically scored 0% against the hand-crafted one. PST values tended to get way too large. So that it started to sac material to get other pieces in a good spot.

Problem is that the cooperativity between pieces is very large in Janggi. Attacking piece locations are only good if you occupy sufficiently many of them, and are ahead in material. But because most games that are won satisfy that condition, the occupancy of those squares correlates very stronly with the score. And the Texel tuning sees that.
amanjpro
Posts: 883
Joined: Sat Mar 13, 2021 1:47 am
Full name: Amanj Sherwany

Re: Evaluating piece value

Post by amanjpro »

hgm wrote: Tue May 25, 2021 3:29 pm I had a very poor experience with that in my Janggi engine, although this might be peculiar to Janggi. The version with a Texel-tuned PST basically scored 0% against the hand-crafted one. PST values tended to get way too large. So that it started to sac material to get other pieces in a good spot.

Problem is that the cooperativity between pieces is very large in Janggi. Attacking piece locations are only good if you occupy sufficiently many of them, and are ahead in material. But because most games that are won satisfy that condition, the occupancy of those squares correlates very stronly with the score. And the Texel tuning sees that.

For me (in Chess) I gained around 100 elo by texel tuning PSQT. Granted I added a condition for the PSQT not to exceed a minimum and maximum value
Jon12345
Posts: 80
Joined: Tue May 11, 2010 6:18 pm

Re: Evaluating piece value

Post by Jon12345 »

Some really useful replies there, thanks.

I just came across this: https://www.chessprogramming.org/Simpli ... n_Function

Are they assuming that a pawn = 100 units, so that a Knight on a4 would equal 270 units?

In this PSQT, a Knight = 3 pawns. But I have read that a Knight = 3.45 pawns. Which is more accurate, according to modern opinion?

I also saw this: https://www.chessprogramming.org/PeSTO% ... n_Function

Which do you think is better? Or should I be looking at the Stockfish PSQT if they have them?

I would be avoiding Texel tuning as that is way beyond my pay grade.
Jon
lucametehau
Posts: 100
Joined: Thu Apr 22, 2021 3:56 pm
Location: Bucharest, Romania
Full name: Metehau Luca

Re: Evaluating piece value

Post by lucametehau »

Well, I have started with the psqt from chessprogramming and they worked pretty good until 2400 elo. Later I added tapered eval, but I couldn't find any EG psqts that work with the MG ones from cp, so I just made them by hand. So, use the cp ones, they are good :D
amanjpro
Posts: 883
Joined: Sat Mar 13, 2021 1:47 am
Full name: Amanj Sherwany

Re: Evaluating piece value

Post by amanjpro »

If you want your engine to act as a unique engine, then start with the first one, and tweak it yourself to better suite your style.
And, as for the piece value, it is best to start with something like this:

p = 100
k = 315
b = 325
r = 515
q = 1000

That ensures that 3 minors are less valuable than 1 queen, 3 pawns are less valuable than a minor, and two minors are more valuable than a rook but almost equal to a rook and a pawn, and two bishops are more valuable than two knights.

You can then start from there and tweak it using Texel tuning maybe
User avatar
lithander
Posts: 881
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Evaluating piece value

Post by lithander »

I initialized the tables with the standard values Pawn = 100, Knight = 300, Bishop = 300, Rook = 500, Queen = 900 and then let texel tuning take over. It preserved these values pretty well on average creating tables that look like this:

Code: Select all

100,  100,  100,  100,  100,  100,  100,  100,
  176,  214,  147,  194,  189,  214,  132,   77,
   82,   88,  106,  113,  150,  146,  110,   73,
   67,   93,   83,   95,   97,   92,   99,   63,
   55,   74,   80,   89,   94,   86,   90,   55,
   55,   70,   68,   69,   76,   81,  101,   66,
   52,   84,   66,   60,   69,   99,  117,   60,
  100,  100,  100,  100,  100,  100,  100,  100,

  116,  228,  271,  270,  338,  213,  278,  191,
  225,  247,  353,  331,  321,  360,  300,  281,
  258,  354,  343,  362,  389,  428,  375,  347,
  300,  332,  325,  360,  349,  379,  339,  333,
  298,  322,  325,  321,  337,  332,  332,  303,
  287,  297,  316,  319,  327,  320,  327,  294,
  276,  259,  300,  304,  308,  322,  296,  292,
  208,  290,  257,  274,  296,  284,  293,  284,

  292,  338,  254,  283,  299,  294,  337,  323,
  316,  342,  319,  319,  360,  385,  343,  295,
  342,  377,  373,  374,  368,  392,  385,  363,
  332,  338,  356,  384,  370,  380,  337,  341,
  327,  354,  353,  366,  373,  346,  345,  341,
  335,  350,  351,  347,  352,  361,  350,  344,
  333,  354,  354,  339,  344,  353,  367,  333,
  309,  341,  342,  325,  334,  332,  302,  313,

  493,  511,  487,  515,  514,  483,  485,  495,
  493,  498,  529,  534,  546,  544,  483,  508,
  465,  490,  499,  497,  483,  519,  531,  480,
  448,  464,  476,  495,  484,  506,  467,  455,
  442,  451,  468,  470,  476,  472,  498,  454,
  441,  461,  468,  465,  478,  481,  478,  452,
  443,  472,  467,  476,  483,  500,  487,  423,
  459,  463,  470,  479,  480,  480,  446,  458,

  865,  902,  922,  911,  964,  948,  933,  928,
  886,  865,  903,  921,  888,  951,  923,  940,
  902,  901,  907,  919,  936,  978,  965,  966,
  881,  885,  897,  894,  898,  929,  906,  915,
  907,  884,  899,  896,  904,  906,  912,  911,
  895,  916,  900,  902,  904,  912,  924,  917,
  874,  899,  918,  908,  915,  924,  911,  906,
  906,  899,  906,  918,  898,  890,  878,  858,

  -11,   70,   55,   31,  -37,  -16,   22,   22,
   37,   24,   25,   36,   16,    8,  -12,  -31,
   33,   26,   42,   11,   11,   40,   35,   -2,
    0,   -9,    1,  -21,  -20,  -22,  -15,  -60,
  -25,   16,  -27,  -67,  -81,  -58,  -40,  -62,
    7,   -2,  -37,  -77,  -79,  -60,  -23,  -26,
   12,   15,  -13,  -72,  -56,  -28,   15,   17,
   -6,   44,   29,  -58,    8,  -25,   34,   28,
   
   ENDGAME

  100,  100,  100,  100,  100,  100,  100,  100,
  277,  270,  252,  229,  240,  233,  264,  285,
  190,  197,  182,  168,  155,  150,  180,  181,
  128,  117,  108,  102,   93,  100,  110,  110,
  107,  101,   89,   85,   86,   83,   92,   91,
   96,   96,   85,   92,   88,   83,   85,   82,
  107,   99,   97,   97,  100,   89,   89,   84,
  100,  100,  100,  100,  100,  100,  100,  100,

  229,  236,  269,  250,  257,  249,  219,  188,
  252,  274,  263,  281,  273,  258,  260,  229,
  253,  264,  290,  289,  278,  275,  263,  243,
  267,  280,  299,  301,  299,  293,  285,  264,
  263,  273,  293,  301,  296,  293,  284,  261,
  258,  276,  278,  290,  287,  274,  260,  255,
  241,  259,  270,  277,  276,  262,  260,  237,
  253,  233,  258,  264,  261,  260,  234,  215,

  288,  278,  287,  292,  293,  290,  287,  277,
  289,  294,  301,  288,  296,  289,  294,  281,
  292,  289,  296,  292,  296,  300,  296,  293,
  293,  302,  305,  305,  306,  302,  296,  297,
  289,  293,  304,  308,  298,  301,  291,  288,
  285,  294,  304,  303,  306,  294,  290,  280,
  285,  284,  291,  299,  300,  290,  284,  271,
  277,  292,  286,  295,  294,  288,  290,  285,

  506,  500,  508,  502,  504,  507,  505,  503,
  505,  506,  502,  502,  491,  497,  506,  501,
  504,  503,  499,  500,  500,  495,  496,  496,
  503,  502,  510,  500,  502,  504,  500,  505,
  505,  509,  509,  506,  504,  503,  496,  495,
  500,  503,  500,  505,  498,  498,  499,  489,
  496,  495,  502,  505,  498,  498,  491,  499,
  492,  497,  498,  496,  493,  493,  497,  480,

  918,  937,  943,  945,  934,  926,  924,  942,
  907,  945,  946,  951,  982,  933,  928,  912,
  896,  921,  926,  967,  963,  937,  924,  915,
  926,  944,  939,  962,  983,  957,  981,  950,
  893,  949,  942,  970,  952,  956,  953,  936,
  911,  892,  933,  928,  934,  942,  934,  924,
  907,  898,  883,  903,  903,  893,  886,  888,
  886,  887,  890,  872,  916,  890,  906,  879,

  -74,  -43,  -23,  -25,  -11,   10,    1,  -12,
  -18,    6,    4,    9,    7,   26,   14,    8,
   -3,    6,   10,    6,    8,   24,   27,    3,
  -16,    8,   13,   20,   14,   19,   10,   -3,
  -25,  -14,   13,   20,   24,   15,    1,  -15,
  -27,  -10,    9,   20,   23,   14,    2,  -12,
  -32,  -17,    4,   14,   15,    5,  -10,  -22,
  -55,  -40,  -23,   -6,  -20,   -8,  -28,  -47,
One trick I found helpful is that I only let the tuner change a value if the benefit is above a certain threshold. That causes the tables to stabilize faster and avoids overfitting.
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
Jon12345
Posts: 80
Joined: Tue May 11, 2010 6:18 pm

Re: Evaluating piece value

Post by Jon12345 »

Are these tables about motivating the engine to move the piece to a better square, rather than just the value of that piece? Take the pawn values in @lithander's post. A pawn on e2 is worth 0.69 pawns. But would you let an opponent capture that pawn in return for 0.69 compensation?
Jon
User avatar
lithander
Posts: 881
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Evaluating piece value

Post by lithander »

Jon12345 wrote: Tue May 25, 2021 5:10 pm Are these tables about motivating the engine to move the piece to a better square, rather than just the value of that piece? Take the pawn values in @lithander's post. A pawn on e2 is worth 0.69 pawns. But would you let an opponent capture that pawn in return for 0.69 compensation?
Why shouldn't it? It has tried attributing both the value 68 and 70 to a pawn on that square and both didn't improve the predictive quality of the evaluation. So it's fair to assume (for the engine) that a pawn on this square is worth exactly 69 points and it plays accordingly.

But it's sadly not true that a set of tables with a better predictive quality (smaller mean-squared error) on the training set is really always resulting in stronger play. For example a lot of tables have great MSE scores but result in the engine playing weird openings. It took me a lot of time to find tables that were working better than PeSTO's...

Feel free to give them a try if you want: http://talkchess.com/forum3/viewtopic.p ... 30#p891122
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess