Page 1 of 1

Approximating Stockfish's Evaluation by PSQTs

Posted: Wed Aug 23, 2017 3:30 pm
by thomasahle
I did some experiments, mostly for fun, that you all may find fun as well.
I made stockfish play 20,000,000 random games to ply 60 at 1ms per move. Each game was made different by always picking a random move from its top 6 pvs.
For each (white) position I read Stockfish's score estimate and recorded it in a table, together with a binary vector representation of the board position.

I then used regression with l1 loss to find the best possible psqts for the given positions. I managed to get an average difference between Stockfish and the simple table evaluation of 1 pawn.

The (normalised) piece values always quickly converged to
Pawn 100, Knight 283, Bishop 323, Rook 481, Queen: 935

The following pictures show the heat map of each table:

Queen and Rook
Image
Bishop and King
Image
Knight and Pawn
Image

I also tried enforcing symmetry, which allowed faster training, though the average loss was the same:

Queen and Rook
Image
Knight and Pawn
Image
Bishop and King
Image

Clearly both of the King tables are somewhat noisy. Even with 20,000,000 games, the king just doesn't wander off to d8/e8 that often.
There are also artefacts coming from the ground truth containing possible future gains, such as the knights being encouraged to go to likely fork positions.

Overall however, the tables seem to have learned some useful things, such at positioning rooks in d1/e1 and promoting pawns.

Do you see any other useful things they have learned or things that are clearly mistakes?

Re: Approximating Stockfish's Evaluation by PSQTs

Posted: Sat Aug 26, 2017 3:06 am
by Dann Corbit
I have seen with a heat map tool made by Les Fernandez that the shape of the black and white heat maps are not the same.

Yet you will often see PSQTs that are a single set of values mirrored for the other side. I think this is a mistake.

Re: Approximating Stockfish's Evaluation by PSQTs

Posted: Sun Aug 27, 2017 11:49 am
by thomasahle
Making different maps for black and white would be interesting. I chose this format because it made it easier to plug the tables into sunfish. My experiments also showed that sunfish played slightly stronger with the asymmetric tables.

Do you have a link to the heat maps you ate referencing?

Re: Approximating Stockfish's Evaluation by PSQTs

Posted: Sun Aug 27, 2017 1:47 pm
by velmarin
Watch this link.

Hay takes you to a chessbasse article and to the author's blog, maybe it still exists.
http://www.talkchess.com/forum/viewtopi ... highlight=

Re: Approximating Stockfish's Evaluation by PSQTs

Posted: Sun Aug 27, 2017 3:51 pm
by thomasahle
I see, but these are just based on where the piece most often goes, right? Not an indication if whether it goes there by its own will, or because it's forced.

Re: Approximating Stockfish's Evaluation by PSQTs

Posted: Sun Aug 27, 2017 8:07 pm
by Dann Corbit
thomasahle wrote:Making different maps for black and white would be interesting. I chose this format because it made it easier to plug the tables into sunfish. My experiments also showed that sunfish played slightly stronger with the asymmetric tables.

Do you have a link to the heat maps you ate referencing?
http://rybkaforum.net/cgi-bin/rybkaforu ... heat%20map

I have not made the detailed ones in a while. My friend Les just updated the tool set, so I will probably redo a really big pile.

Re: Approximating Stockfish's Evaluation by PSQTs

Posted: Mon Aug 28, 2017 3:12 pm
by thomasahle
Dann Corbit wrote:
thomasahle wrote:Making different maps for black and white would be interesting. I chose this format because it made it easier to plug the tables into sunfish. My experiments also showed that sunfish played slightly stronger with the asymmetric tables.

Do you have a link to the heat maps you ate referencing?
http://rybkaforum.net/cgi-bin/rybkaforu ... heat%20map

I have not made the detailed ones in a while. My friend Les just updated the tool set, so I will probably redo a really big pile.
These are nice, but am I correct that they are simply based on how often a piece is seen on the particular square, rather than any kind of evaluation? So if a knight very often captured a rook in the corner, the corner would have a high value for the knight. Even though it is not a good position for the piece?

Re: Approximating Stockfish's Evaluation by PSQTs

Posted: Mon Aug 28, 2017 8:49 pm
by Dann Corbit
thomasahle wrote:
Dann Corbit wrote:
thomasahle wrote:Making different maps for black and white would be interesting. I chose this format because it made it easier to plug the tables into sunfish. My experiments also showed that sunfish played slightly stronger with the asymmetric tables.

Do you have a link to the heat maps you ate referencing?
http://rybkaforum.net/cgi-bin/rybkaforu ... heat%20map

I have not made the detailed ones in a while. My friend Les just updated the tool set, so I will probably redo a really big pile.
These are nice, but am I correct that they are simply based on how often a piece is seen on the particular square, rather than any kind of evaluation? So if a knight very often captured a rook in the corner, the corner would have a high value for the knight. Even though it is not a good position for the piece?
They are based on:
1. Being in a band of plies
2. Whether a particular side won/lost/drew {selectable by the tool user}

Hence, you could say it is outcome driven. This is a good approach if "the proof of the pudding is in the eating".

Of course, it is possible that early plies are played by rote {or by book, which amounts to the same thing} and bad moves are included for this reason.

On the other hand, when you insert a million or so high quality games, I would expect that things tend to even out.

It is up to the user to choose the data upon which to base the analysis.

Re: Approximating Stockfish's Evaluation by PSQTs

Posted: Mon Sep 04, 2017 8:25 am
by Ferdy
thomasahle wrote:I did some experiments, mostly for fun, that you all may find fun as well.
I made stockfish play 20,000,000 random games to ply 60 at 1ms per move. Each game was made different by always picking a random move from its top 6 pvs.
For each (white) position I read Stockfish's score estimate and recorded it in a table, together with a binary vector representation of the board position.

I then used regression with l1 loss to find the best possible psqts for the given positions. I managed to get an average difference between Stockfish and the simple table evaluation of 1 pawn.
Thanks for posting this.

I have troubled understanding your process.
How do you find the best possible pst given the following example.

Code: Select all

Pos: 1, scorecp: 25, Q: e1, gameresult: 1-0
Pos: 2, scorecp: 30, Q: c2, gameresult: 1-0
Pos: 3, scorecp: 10, Q: e1, gameresult: 1/2-1/2
What will be the value of e1 sq in the queen pst output?

I understand that L1 loss is using sum of absolute difference. How do you map the score 25, 30, 10 to calculate the error?

Re: Approximating Stockfish's Evaluation by PSQTs

Posted: Fri Jul 26, 2019 11:43 am
by thomasahle
I have troubled understanding your process.
How do you find the best possible pst given the following example.

Code: Select all

Pos: 1, scorecp: 25, Q: e1, gameresult: 1-0
Pos: 2, scorecp: 30, Q: c2, gameresult: 1-0
Pos: 3, scorecp: 10, Q: e1, gameresult: 1/2-1/2
I assume you mean that the positions each have only one piece on the board.
In this case, we want to mininmize

Code: Select all

|Val(Q,e1) - 25| + |Val(Q,c2) - 10| + |Val(Q,e1) - 10|
over Val.