Approximating Stockfish's Evaluation by PSQTs

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
thomasahle
Posts: 51
Joined: Thu Feb 27, 2014 7:19 pm

Approximating Stockfish's Evaluation by PSQTs

Post by thomasahle » Wed Aug 23, 2017 1:30 pm

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?

Dann Corbit
Posts: 9289
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: Approximating Stockfish's Evaluation by PSQTs

Post by Dann Corbit » Sat Aug 26, 2017 1:06 am

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.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.

thomasahle
Posts: 51
Joined: Thu Feb 27, 2014 7:19 pm

Re: Approximating Stockfish's Evaluation by PSQTs

Post by thomasahle » Sun Aug 27, 2017 9:49 am

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?

User avatar
velmarin
Posts: 1580
Joined: Mon Feb 21, 2011 8:48 am

Re: Approximating Stockfish's Evaluation by PSQTs

Post by velmarin » Sun Aug 27, 2017 11:47 am

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=

thomasahle
Posts: 51
Joined: Thu Feb 27, 2014 7:19 pm

Re: Approximating Stockfish's Evaluation by PSQTs

Post by thomasahle » Sun Aug 27, 2017 1:51 pm

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.

Dann Corbit
Posts: 9289
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: Approximating Stockfish's Evaluation by PSQTs

Post by Dann Corbit » Sun Aug 27, 2017 6:07 pm

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.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.

thomasahle
Posts: 51
Joined: Thu Feb 27, 2014 7:19 pm

Re: Approximating Stockfish's Evaluation by PSQTs

Post by thomasahle » Mon Aug 28, 2017 1:12 pm

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?

Dann Corbit
Posts: 9289
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: Approximating Stockfish's Evaluation by PSQTs

Post by Dann Corbit » Mon Aug 28, 2017 6:49 pm

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.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.

Ferdy
Posts: 3645
Joined: Sun Aug 10, 2008 1:15 pm
Location: Philippines

Re: Approximating Stockfish's Evaluation by PSQTs

Post by Ferdy » Mon Sep 04, 2017 6:25 am

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?

Post Reply