The PSTs of Carnivor

Discussion of chess software programming and technical issues.

Moderator: Ras

Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: The PSTs of Carnivor

Post by Mike Sherwin »

lithander wrote: Wed Mar 10, 2021 11:03 pm

Code: Select all

#PST from Carnivor by Mike Sherwin| Source: http://talkchess.com/forum3/viewtopic.php?f=7&t=76831&p=886615

Pawn 100
  0|  0|  0|  0|  0|  0|  0|  0
 40| 60| 60| 80| 80| 60| 60| 40
 20| 40| 40| 60| 60| 40| 40| 20
 10| 16| 12| 30| 30| 12|  8|  6
  8| 14| 16| 20| 20|  8|  6|  4
 12|  8|  0|-10|-10|  0|  4|  6
  4|  4|-24|-30|-30|  8|  8|  4
  0|  0|  0|  0|  0|  0|  0|  0

Knight 290   
  0|  6| 12| 12| 12| 12|  6|  0
  6| 12| 24| 36| 36| 24| 12|  6
 12| 24| 36| 40| 40| 36| 24| 12
 12| 24| 36| 42| 42| 36| 24| 12
 12| 24| 36| 40| 40| 36| 24| 12
 12| 24| 30| 36| 36| 38| 24| 12
  6| 12| 24| 30| 26| 24| 12|  6
  0|-10| 12| 12| 12| 12|-10|  0

Bishop 330
 6 |  0|  0|  0|  0|  0|  0|  6
 0 | 18| 20| 20| 20| 20| 18|  0
 0 | 12| 30| 24| 24| 30| 12|  0
 0 | 30| 24| 32| 32| 24| 30|  0
 16| 12| 32| 32| 32| 32| 12| 16
 0 | 20| 30| 12| 12| 30| 20|  0
 10| 30| 12| 12| 12| 12| 30| 10
 6 |  0|  0|  0|  0|  0|  0|  6

Rook 500
 22| 22| 22| 22| 22| 22| 22| 22
 24| 24| 24| 24| 24| 24| 24| 24
  6|  8| 10| 12| 12| 10|  8|  6
  4|  6|  8| 10| 10|  8|  6|  4
  4|  6|  8| 10| 10|  8|  6|  4
  6|  8| 10| 12| 12| 10|  8|  6
  8| 10| 10| 22| 22| 10| 10|  8
  8| 10| 12| 20| 20| 12| 10|  8

Queen 900
 18| 18| 18| 18| 18| 18| 18| 18
 18| 20| 20| 20| 20| 20| 20| 18
 16| 18| 20| 20| 20| 20| 18| 16
 16| 18| 20| 20| 20| 20| 18| 16
 14| 16| 18| 18| 18| 18| 16| 14
 14| 16| 18| 18| 18| 18| 16| 14
 14| 16| 16| 16| 16| 16| 16| 14
 14| 14| 14| 14| 14| 14| 14| 14

King 66666			
-10|-10|-10|-10|-10|-10|-10|-10
-10|  0|  0|  0|  0|  0|  0|-10
-10|  0| 20| 20| 20| 20|  0|-10
-10|  0| 20| 40| 40| 20|  0|-10
-10|  0| 20| 20| 20| 20|  0|-10
-20|-20|-20|-20|-20|-20|-20|-20
-30|-30|-30|-30|-30|-30|-30|-30
 20| 60| 20|-40|  0| 20| 60| 20
The POV of my files are as the white player sees a chess board. I'm running a few games now against my default values. And because I've been testing all the other PSTs against Rustic too I'm also playing yours against Rustic Alpha 1 now. Let's see if Carnivore's can beat texel-tuned Sunfish's! (which perform best against Rustic)
The kings probably do need an endgame PST. I can try reducing the bonus for g1/8, h1/8 and b1/8, a1/8 at some point. Like I said Car was a toy engine. I just like the style of play and once the kings are fixed it should do okay. But, probably not with the kings like they are now.
User avatar
lithander
Posts: 915
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: The PSTs of Carnivor

Post by lithander »

Mike Sherwin wrote: Thu Mar 11, 2021 12:39 am The kings probably do need an endgame PST. I can try reducing the bonus for g1/8, h1/8 and b1/8, a1/8 at some point. Like I said Car was a toy engine. I just like the style of play and once the kings are fixed it should do okay. But, probably not with the kings like they are now.
This might explain why Car's PSTs didn't do so well in my tests.

Code: Select all

Score of MinimalChess 0.3 Carnivor vs MinimalChess 0.3: 126 - 134 - 177  [0.491] 437
Elo difference: -6.4 +/- 25.1, LOS: 31.0 %, DrawRatio: 40.5 %
Self play strength was about equal but the draw ratio was really high because both versions often were in disagreement in their evaluation. When both thought they were losing they both accepted a draw by 3-ply-move-repetition. (I might bump the contempt value again above zero, I really don't like to see my engine play lame moves like that in a balanced position)

Against Rustic it played much worse with Carnivor's PSTs compared to e.g. Sunfish's.

Code: Select all

Score of MinimalChess 0.3 Carnivor vs Rustic: 217 - 576 - 207  [0.321] 1000
Elo difference: -130.5 +/- 20.1, LOS: 0.0 %, DrawRatio: 20.7 %

Code: Select all

Score of MinimalChess 0.3 Sunfish vs Rustic: 321 - 488 - 191  [0.416] 1000
Elo difference: -58.6 +/- 19.6, LOS: 0.0 %, DrawRatio: 19.1 %
But if you give me a new KING table I'll run these tests again. I got a lot of idle cores during the day! ;) And playing chess is at least more worthwhile than mining cryptocoins :P
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: The PSTs of Carnivor

Post by Mike Sherwin »

lithander wrote: Thu Mar 11, 2021 11:54 am
Mike Sherwin wrote: Thu Mar 11, 2021 12:39 am The kings probably do need an endgame PST. I can try reducing the bonus for g1/8, h1/8 and b1/8, a1/8 at some point. Like I said Car was a toy engine. I just like the style of play and once the kings are fixed it should do okay. But, probably not with the kings like they are now.
This might explain why Car's PSTs didn't do so well in my tests.

Code: Select all

Score of MinimalChess 0.3 Carnivor vs MinimalChess 0.3: 126 - 134 - 177  [0.491] 437
Elo difference: -6.4 +/- 25.1, LOS: 31.0 %, DrawRatio: 40.5 %
Self play strength was about equal but the draw ratio was really high because both versions often were in disagreement in their evaluation. When both thought they were losing they both accepted a draw by 3-ply-move-repetition. (I might bump the contempt value again above zero, I really don't like to see my engine play lame moves like that in a balanced position)

Against Rustic it played much worse with Carnivor's PSTs compared to e.g. Sunfish's.

Code: Select all

Score of MinimalChess 0.3 Carnivor vs Rustic: 217 - 576 - 207  [0.321] 1000
Elo difference: -130.5 +/- 20.1, LOS: 0.0 %, DrawRatio: 20.7 %

Code: Select all

Score of MinimalChess 0.3 Sunfish vs Rustic: 321 - 488 - 191  [0.416] 1000
Elo difference: -58.6 +/- 19.6, LOS: 0.0 %, DrawRatio: 19.1 %
But if you give me a new KING table I'll run these tests again. I got a lot of idle cores during the day! ;) And playing chess is at least more worthwhile than mining cryptocoins :P
Thanks Thomas, I appreciate you taking the time to do this. I will work on the king table. This morning I downloaded Sunfish and I read that it doesn't distinguish between middlegame and endgame so having a look at the Sunfish king table its g1 bonus is 40 instead of CAR's 60 and there is a path of low resistance for the king to come into the center via g2, g4, f5, f6 then it absolutely hates e6 (-67) for the king but loves d6 (+44). That part makes no sense at all unless it somehow acts synergistically with the other tables. This confirms the notion that I need to reduce g1 to 40 which is exactly what I was planning to try first anyway. I'll be back!
User avatar
lithander
Posts: 915
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: The PSTs of Carnivor

Post by lithander »

For what it's worth here's a KING table I use for the PSTs that are no sunfish and would otherwise require a distinct endgame table like rustic and the "simple evaluation" one.

Code: Select all

King 66666			
-10| 10|  10| -20| -20|  10| 10| -10
-20|  0|  20|  20|  20|  20|  0| -20
-30|  0|   0|  10|   0|   0|  0| -30
-30|  0|   0|   0|   0|   0|  0| -30
-30|-10|   0|   0|   0|   0|-10| -30
-20|-20| -20| -30| -30| -20|-20| -20
  0|  0| -10| -30| -30| -10|  0|   0
 10| 20|  10| -10| -10|   0| 20|  10
What I wanted the KING to do is to prefer castling and stay there but once he left the corner for whatever reason he'd get "pulled" into the center and there he'd find a few 20s on the 7th rank so that he wouldn't go back to the castling corners when the pressure there subsided but could actually help with promotion instead. And I gave a penalty to the corners. In self play of MMC 0.3 this modified simple evaluation did win more games against sunfish's tuned PSTs than it lost. But against Rustic the sunfish version did much better and Marcel observed MMC 0.3 not converting won endgames into actual victories. So I guess it didn't turn out so great after all! ;)

This is why I'll want to give tapered eval ala PeSTO a try over the following weekend. But I'm also very curious what you can cook up because sunfish somehow managed to encode some endgame knowledge into it's PST through the automatic tuning process and I really wonder if a good human chess player could too. (I can't obviously, but I'm only rated 1000 on chess.com)
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: The PSTs of Carnivor

Post by mvanthoor »

lithander wrote: Thu Mar 11, 2021 6:00 pm This is why I'll want to give tapered eval ala PeSTO a try over the following weekend. But I'm also very curious what you can cook up because sunfish somehow managed to encode some endgame knowledge into it's PST through the automatic tuning process and I really wonder if a good human chess player could too. (I can't obviously, but I'm only rated 1000 on chess.com)
One of the reasons your PST above can't convert wins is because the king gets stuck on the 7th rank. There is not enough incentive to leave it, so you can't mate with K+R vs. K because you can't see 15-20 moves ahead (yet). What you need, is a table where the center is 0, and all of the other squares are negative. Thus, the king wants to be in the center if he is not there already. Then, the other king needs to be driven to the edge.

For other pieces, you can make somewhat generalized tables, like I did; and a tuner can do it better. For the king, you can't really encode both the opening and end game table into one, because they contradict. A tuner can do it, by jacking with the values for the other pieces, and by encoding other positional knowledge in the PST's. That's the reason why the tuned tables look so weird; they encode knowledge that the evaluation function itself doesn't have yet. (Thus, you need to retune all variables in the evaluation function as soon as you add an evaluation term.)

The trick is to make each step away from the center negative, and make the margin larger each time. So, the first step away is -20 (20 down from previous), but the next is -50 (30 down from previous) and the edge is -90 (40 down from previous). Thus, the king in the center is going to assist with mate, because he can now step out of the center: doing so is negative, but when it drives the other king to the edge, it will be MORE negative for that king.

If king A is in the center, his PST value is 0.
If king B is one step out of the center, his value is -20.

King A thus has a gross value of +20, compared to king B.

Now if a rook drives king B one step closer to the edge, king B's value becomes -50.
Now King A must follow, out of the center, or mate will never occur. When HE steps out of the center, his value becomes -20.

But... compared to King B, he is now at +30.

Thus, King A will step out of the center, because for King A, the evaluation will go from +20 better to +30 better than king B.

Essentially, this is already a tiny version of a tapered evaluation, with a very hard switch from 0% endgame to 100% endgame, for one piece only.
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: The PSTs of Carnivor

Post by Mike Sherwin »

lithander wrote: Thu Mar 11, 2021 6:00 pm For what it's worth here's a KING table I use for the PSTs that are no sunfish and would otherwise require a distinct endgame table like rustic and the "simple evaluation" one.

Code: Select all

King 66666			
-10| 10|  10| -20| -20|  10| 10| -10
-20|  0|  20|  20|  20|  20|  0| -20
-30|  0|   0|  10|   0|   0|  0| -30
-30|  0|   0|   0|   0|   0|  0| -30
-30|-10|   0|   0|   0|   0|-10| -30
-20|-20| -20| -30| -30| -20|-20| -20
  0|  0| -10| -30| -30| -10|  0|   0
 10| 20|  10| -10| -10|   0| 20|  10
What I wanted the KING to do is to prefer castling and stay there but once he left the corner for whatever reason he'd get "pulled" into the center and there he'd find a few 20s on the 7th rank so that he wouldn't go back to the castling corners when the pressure there subsided but could actually help with promotion instead. And I gave a penalty to the corners. In self play of MMC 0.3 this modified simple evaluation did win more games against sunfish's tuned PSTs than it lost. But against Rustic the sunfish version did much better and Marcel observed MMC 0.3 not converting won endgames into actual victories. So I guess it didn't turn out so great after all! ;)

This is why I'll want to give tapered eval ala PeSTO a try over the following weekend. But I'm also very curious what you can cook up because sunfish somehow managed to encode some endgame knowledge into it's PST through the automatic tuning process and I really wonder if a good human chess player could too. (I can't obviously, but I'm only rated 1000 on chess.com)
Just my opinion but 20s as high values on the 7th rank is too close to the eighth rank if the engine has any depth at all. However, it seems like your test are at very fast time controls so maybe, idk, the depth your engine reaches is not enough to see that if the king is in the center that it can go to the 7th to help a pawn promote. I think what I'm trying to say is that if the engine searches deep enough the high scores should be in the center so it can head anywhere on the board as needed. Why do the PSTs have to be 100% static? Can't we just work from copies and modify the copies according to the game phase? Or do like I did in RomiChess just compute the PSTs at the root. So just copy the static tables at the root and then adjust the values with mobility for a minimal engine and anything that can be thought of for a more advanced engine.

Have you tested against TSCP1.81? If so can you post the results for the various PSTs. I recommend TSCP because it does have a standard and decent evaluation function. It might result in better test data because it would not be as likely to fall into the trap a > b > c > a when testing PSTs because all static PSTs will be strong in some positions and weak in others.

As for me and Bric right now we are on this road and a huge tree has fallen across the road and we can't get past it. It's just the strangest bug I have ever had to squash. The white king when it reaches a point that it is clear that the game is lost makes a beeline for a1 and when it gets there it commits suicide by capturing itself. Now I just saw it from the black side all the way from g8 to a1. It happens about 1 in 20 games. And only in Arena and not in the debugger where it plays faultlessly. I'm so frustrated right now that I just have to walk away for a moment and think what to try next. The following king PST seems better. It did convert a game that it would not have otherwise.

[pgn][Event "Fruit"]
[Site "MASTER"]
[Date "2021.03.11"]
[Round "1"]
[White "Bricabrac"]
[Black "Tscp181"]
[Result "1-0"]
[BlackElo "2200"]
[ECO "A67"]
[Opening "Benoni"]
[Time "10:09:18"]
[Variation "Four Pawns, Taimanov, 8...Nbd7"]
[WhiteElo "2200"]
[TimeControl "0+8"]
[Termination "adjudication"]
[PlyCount "172"]
[WhiteType "human"]
[BlackType "human"]

1. d4 Nf6 2. c4 c5 3. d5 e6 4. Nc3 exd5 5. cxd5 d6 6. e4 g6 7. Nf3 Bg7 8.
Bb5+ {(f1b5 b8d7 c1f4 a7a6 b5d3 d8b6 a1b1 e8g8 e1g1 f8d8) +0.50/10 7} Bd7
{(c8d7 d1d3 d7b5 d3b5 d8d7 b5e2 e8g8 e1g1) -0.70/6 8} 9. Bd3 {(b5d3 e8g8
e1g1 b8a6 c1f4 d8b6 a1b1 a8e8 a2a3 a6c7 b2b4) +0.66/11 7} Ng4 {(f6g4 e1g1
g7c3 b2c3 e8g8 c1f4) -0.75/6 8} 10. Qb3 {(d1b3 d8c7 e1g1 e8g8 c1g5 b8a6
c3b5 c7b6 d3c4 g4e5) +0.80/10 8} Qc7 {(d8c7 e1g1 e8g8 c1g5 g4e5 d3e2)
-0.86/6 8} 11. Nb5 {(c3b5 d7b5 d3b5 e8f8 e1g1 b8d7 c1f4 a7a6 b5e2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g8 f6g6 g8f8 h4h5 f8e7 h5h6
e7e6 h6h7 e6d5 h7h8q d5e4 h8e5 e4d3 g6f5 d3c4) +14.28/18 8} Kh7 {(g8h7 f6f7
h7h8 h4h5 g6h5 g5f6 h8h7 g4g5 h5h4 g5g6 h7h6 g6g7 h4h3 g7g8q) -10.31/11 8}
84. Bf4 {(g5f4 h7h8 f6g6 h8g8 h4h5 g8f8 h5h6 f8e8 f4g3 e8e7 h6h7 e7d7 h7h8q
d7e6 g3e5 e6d5 g6f5 d5c5 f5e4) +14.36/19 7} Kg8 {(h7g8 f6g6 g8f8 h4h5 f8e7
h5h6 e7e6 h6h7 e6d5 g6f5 d5d4 h7h8q) -13.39/11 7} 85. Kxg6 {(f6g6 g8f8 h4h5
f8e7 h5h6 e7e8 g6f6 e8d7 h6h7 d7c6 h7h8q c6d5 g4g5 d5e4 f4e5 e4d5 g5g6 d5e4
g6g7) +14.70/19 7} Kf8 {(g8f8 h4h5 f8e7 h5h6 e7e6 h6h7 e6d5 g6f5 d5d4 h7h8q
d4d5 g4g5) -13.61/11 8} 86. Be5 {(f4e5 f8e7 h4h5 e7e6 e5a1 e6d5 a1f6 d5e4
h5h6 e4f4 g4g5 f4e3 h6h7 e3f4 h7h8q f4e4 f6d4) +14.00/17 8} Ke7 {(f8e7 e5f6
e7d7 g4g5 d7c8 h4h5 c8b7 h5h6 b7c6 h6h7 c6d5 h7h8q) -13.41/11 8 Arena
Adjudication} 1-0
[/pgn]

Code: Select all

s32 wkPST[64] = {
   10,  40,  30, -40, -30,  30,  40,  10,
  -10,  20, -10,   0,   0, -10,  20, -10,
  -20, -20, -20, -20, -20, -20, -20, -20,
  -10,   0,  20,  30,  30,  20,   0, -10,
  -10,   0,  20,  30,  30,  20,   0, -10,
  -10,   0,  20,  20,  20,  20,   0, -10,
  -10,   0,   0,   0,   0,   0,   0, -10,
  -10, -10, -10, -10, -10, -10, -10, -10
};
User avatar
lithander
Posts: 915
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: The PSTs of Carnivor

Post by lithander »

Mike Sherwin wrote: Thu Mar 11, 2021 7:55 pm

Code: Select all

s32 wkPST[64] = {
   10,  40,  30, -40, -30,  30,  40,  10,
  -10,  20, -10,   0,   0, -10,  20, -10,
  -20, -20, -20, -20, -20, -20, -20, -20,
  -10,   0,  20,  30,  30,  20,   0, -10,
  -10,   0,  20,  30,  30,  20,   0, -10,
  -10,   0,  20,  20,  20,  20,   0, -10,
  -10,   0,   0,   0,   0,   0,   0, -10,
  -10, -10, -10, -10, -10, -10, -10, -10
};
I replaced the KING table with this one and ran some tests again and the tables are definitely an improvement, but not a massive one. (~20 ELO) By now I'm almost convinced that the approach of using static PSTs as the only term in the evaluation is just too simplistic.

Code: Select all

Score of MinimalChess 0.3 vs MinimalChess 0.3 Carnivor: 334 - 364 - 302  [0.485] 1000
Elo difference: -10.4 +/- 18.0, LOS: 12.8 %, DrawRatio: 30.2 %

Score of Rustic vs MinimalChess 0.3 Carnivor: 571 - 255 - 174  [0.658] 1000
Elo difference: 113.7 +/- 20.4, LOS: 100.0 %, DrawRatio: 17.4 %
Mike Sherwin wrote: Thu Mar 11, 2021 7:55 pm Have you tested against TSCP1.81? If so can you post the results for the various PSTs.
I have run tests against TSCP1.81 but not with all PST sets. Only the default one. That you can put PSTs from other programs in a text file and MMC will play by them is just a gimmick feature. It takes too long if I repeat all tests 4x or 5x times so that I know exactly how a certain set of PSTs performs. To be honest I wasn't even aware of the fundamental problems my current evaluation has in endgame situations until Marcel pointed that out...
mvanthoor wrote: Thu Mar 11, 2021 7:23 pm One of the reasons your PST above can't convert wins is because the king gets stuck on the 7th rank. There is not enough incentive to leave it, so you can't mate with K+R vs. K because you can't see 15-20 moves ahead (yet). What you need, is a table where the center is 0, and all of the other squares are negative. Thus, the king wants to be in the center if he is not there already. Then, the other king needs to be driven to the edge.
...and after that I reviewed a few PGNs and setup a few cases where I gave MinimalChess a Queen and King vs a lone King, or a Rook or two Bishops and MMC was just failing to win the game regardless of what PSTs I used. Even the sunfish ones didn't convert.

I tested the same setup with weaker engines and some of them played same situations flawlessly. That's very disappointing but I'm not sure how to address it, yet. The evaluation part is harder to do for me because it requires chess knowledge and not just programming experience. While I understand how the PST values influence the way the engine plays I don't know why the values are what they are in the PSTs I've used so far. And this caused the above mentioned problems without me even being aware of them. The consequence for me is that I need to "own" that part of my engine too, even if at first it means a regression in playing strength.
Mike Sherwin wrote: Thu Mar 11, 2021 7:55 pm Just my opinion but 20s as high values on the 7th rank is too close to the eighth rank if the engine has any depth at all. However, it seems like your test are at very fast time controls so maybe, idk, the depth your engine reaches is not enough to see that if the king is in the center that it can go to the 7th to help a pawn promote. I think what I'm trying to say is that if the engine searches deep enough the high scores should be in the center so it can head anywhere on the board as needed. Why do the PSTs have to be 100% static? Can't we just work from copies and modify the copies according to the game phase? Or do like I did in RomiChess just compute the PSTs at the root. So just copy the static tables at the root and then adjust the values with mobility for a minimal engine and anything that can be thought of for a more advanced engine.
The time controls are 3 seconds + 500ms per move. The PSTs don't "have" to be static but that was the first thing I've tried. Before that I was only counting material, when I tried PSTs the playing strength improved massively and I thought that meant the evaluation was doing it's job. I have to admit that I don't really understand everything you said above. The only conclusion I'm ready to make at this point is that I need to study this topic more. Like actually reading books on chess. :P

If you have any tips regarding where to start reading let me know. (You mentioned mobility for example)
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: The PSTs of Carnivor

Post by mvanthoor »

Mike Sherwin wrote: Thu Mar 11, 2021 7:55 pm Have you tested against TSCP1.81? If so can you post the results for the various PSTs. I recommend TSCP because it does have a standard and decent evaluation function. It might result in better test data because it would not be as likely to fall into the trap a > b > c > a when testing PSTs because all static PSTs will be strong in some positions and weak in others.
No it doesn't... TSCP is fun to watch, but it's a one-trick pony, whose trademark is destroying pawn structures and creating passed pawns. Even Alpha 2, which will probably be rated higher than TSCP after testing, will also probably score a lower rating against TSCP than expected, because it doesn't have any pawn-related evaluations yet. If you add passed pawns (and how dangerous they are) and try to prevent double/triple pawns, it'll gain you somewhere between 100-125 Elo, and suddenly your results against specifically TSCP will skyrocket.
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: The PSTs of Carnivor

Post by mvanthoor »

lithander wrote: Fri Mar 12, 2021 2:14 am ...and after that I reviewed a few PGNs and setup a few cases where I gave MinimalChess a Queen and King vs a lone King, or a Rook or two Bishops and MMC was just failing to win the game regardless of what PSTs I used. Even the sunfish ones didn't convert.

I tested the same setup with weaker engines and some of them played same situations flawlessly. That's very disappointing but I'm not sure how to address it, yet. The evaluation part is harder to do for me because it requires chess knowledge and not just programming experience. While I understand how the PST values influence the way the engine plays I don't know why the values are what they are in the PSTs I've used so far. And this caused the above mentioned problems without me even being aware of them. The consequence for me is that I need to "own" that part of my engine too, even if at first it means a regression in playing strength.
I experienced the same, but the other way around.

I didn't have a lot of experience in chess programming a year ago, and when I got to the point where MMC is now about 6 months ago, I had the same issue as you. For me, as a chess player, mating with K+Q vs. K and K+R vs. K is so completely trivial, that I couldn't at first understand why my engine would be that stupid.

The reason why it doesn't work, is because the engine can't see 10-20 moves ahead; it can't see the mate from the position it is in. It doesn't know, however, that the lone king must be at the edge to mate it. If you just use your midgame/opening PST, your king will be stuck in the corner it castled to, and the engine will keep playing around with the queen in the middle of the board.

After HGM pointed out to me that I need an endgame PST with massive penalties that become bigger with each step, just to teach the engine that a king on the edge in the endgame is NOT good for the lone king, it was easy.

The only two changes I made were:
- Create the king endgame PST Rustic now has
- Switch to that PST as soon as one of the sides has an evaluation of less than 1 pawn (so only the king is on the board; no squares in any PST has a value larger than or smaller than +99 or -99).

It makes the engine play a bit beginner-like sometimes. I can see a mate coming, but the engine can't, because it has no other evaluation except material and PST's. In such a case the engine will whittle the opponent down to a bare king, piece by piece (because that is what it knows how to do), and then the king endgame table kicks in. The strong king will race to the center, and from there, will proceed to help mate the other king.

As said, it's a beginner-like way of playing such endgames, but that doesn't matter. If you use Rustic's endgame PST and then switch to that if the evaluation is less than 100 cp for one player, the engine should convert K+Q vs. King and K+R vs. King without issue. Mine did; it gained about 60 Elo by not botching games.

And you're right: to understand the PST's I wrote, you have to have some chess knowledge. Quite a bit of positional knowledge is written into them; there's even some opening theory in there. Sunfish and other tables? You can't understand them. I can't either. They contain knowledge of the evaluation function of whatever helped tune them.

I could explain the PST values in general terms; it would also make a good piece for the tutorial site I'm writing :)

Also: don't put too much effort in your evaluation function. First:
- Get move sorting in order (pun intended). Have PV Move, Killer, History ordering.
- Add a transposition table and add PV Move ordering

Then your basic engine will be done, and as you can see with Rustic, it will already play close to 1800 Elo. (Rustic doesn't even have PV Move, Killer, and History ordering yet... I wonder how much they will gain.)

At this point, I'll be looking into Texel Tuning to make the basic engine as strong as possible, and so I don't have to tinker with the PST's any longer by myself. If you have some good PST's, you can skip this step for later. I don't, because the next steps are:

- Tapered evaluation, which can then be Texel tuned. Big Elo gain by both the tapering, and the tuning, without any chess knowledge needed.

- Add Aspiration Windows to iterative deepening / alpha-beta (speed-up)
- Add Principal Variation Search to alpha-beta (speed-up)
- Add null move (massive speed-up)
- Add as many other pruning options as you can understand; one by one. Futility pruning, mate distance pruning, WhatEverPruning... I must admit, I still have to study many of those.
- Keep re-tuning the tapered evaluation as you improve the search function.

This is the path that was taken by the PESTO engine, and it reached a massive strength doing so. It requires studying algorithms, and it requires programming experience and lots of testing, but no chess knowledge. So you can take your time and actually study some chess. Then at the end you can start implementing the easier evaluation terms.

The trick is to go slow, and do only ONE function at a time, and not try to get carried away in an urge to get your engine as high up in the rating list as possible. Understand the code you write and why you write it; the evaluation, which requires only minimal programming knowledge and a lot of chess knowledge, can wait... precisely because it can be tuned.
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: The PSTs of Carnivor

Post by Mike Sherwin »

lithander wrote: Fri Mar 12, 2021 2:14 am
Mike Sherwin wrote: Thu Mar 11, 2021 7:55 pm

Code: Select all

s32 wkPST[64] = {
   10,  40,  30, -40, -30,  30,  40,  10,
  -10,  20, -10,   0,   0, -10,  20, -10,
  -20, -20, -20, -20, -20, -20, -20, -20,
  -10,   0,  20,  30,  30,  20,   0, -10,
  -10,   0,  20,  30,  30,  20,   0, -10,
  -10,   0,  20,  20,  20,  20,   0, -10,
  -10,   0,   0,   0,   0,   0,   0, -10,
  -10, -10, -10, -10, -10, -10, -10, -10
};
I replaced the KING table with this one and ran some tests again and the tables are definitely an improvement, but not a massive one. (~20 ELO) By now I'm almost convinced that the approach of using static PSTs as the only term in the evaluation is just too simplistic.

Code: Select all

Score of MinimalChess 0.3 vs MinimalChess 0.3 Carnivor: 334 - 364 - 302  [0.485] 1000
Elo difference: -10.4 +/- 18.0, LOS: 12.8 %, DrawRatio: 30.2 %

Score of Rustic vs MinimalChess 0.3 Carnivor: 571 - 255 - 174  [0.658] 1000
Elo difference: 113.7 +/- 20.4, LOS: 100.0 %, DrawRatio: 17.4 %
Mike Sherwin wrote: Thu Mar 11, 2021 7:55 pm Have you tested against TSCP1.81? If so can you post the results for the various PSTs.
I have run tests against TSCP1.81 but not with all PST sets. Only the default one. That you can put PSTs from other programs in a text file and MMC will play by them is just a gimmick feature. It takes too long if I repeat all tests 4x or 5x times so that I know exactly how a certain set of PSTs performs. To be honest I wasn't even aware of the fundamental problems my current evaluation has in endgame situations until Marcel pointed that out...
mvanthoor wrote: Thu Mar 11, 2021 7:23 pm One of the reasons your PST above can't convert wins is because the king gets stuck on the 7th rank. There is not enough incentive to leave it, so you can't mate with K+R vs. K because you can't see 15-20 moves ahead (yet). What you need, is a table where the center is 0, and all of the other squares are negative. Thus, the king wants to be in the center if he is not there already. Then, the other king needs to be driven to the edge.
...and after that I reviewed a few PGNs and setup a few cases where I gave MinimalChess a Queen and King vs a lone King, or a Rook or two Bishops and MMC was just failing to win the game regardless of what PSTs I used. Even the sunfish ones didn't convert.

I tested the same setup with weaker engines and some of them played same situations flawlessly. That's very disappointing but I'm not sure how to address it, yet. The evaluation part is harder to do for me because it requires chess knowledge and not just programming experience. While I understand how the PST values influence the way the engine plays I don't know why the values are what they are in the PSTs I've used so far. And this caused the above mentioned problems without me even being aware of them. The consequence for me is that I need to "own" that part of my engine too, even if at first it means a regression in playing strength.
Mike Sherwin wrote: Thu Mar 11, 2021 7:55 pm Just my opinion but 20s as high values on the 7th rank is too close to the eighth rank if the engine has any depth at all. However, it seems like your test are at very fast time controls so maybe, idk, the depth your engine reaches is not enough to see that if the king is in the center that it can go to the 7th to help a pawn promote. I think what I'm trying to say is that if the engine searches deep enough the high scores should be in the center so it can head anywhere on the board as needed. Why do the PSTs have to be 100% static? Can't we just work from copies and modify the copies according to the game phase? Or do like I did in RomiChess just compute the PSTs at the root. So just copy the static tables at the root and then adjust the values with mobility for a minimal engine and anything that can be thought of for a more advanced engine.
The time controls are 3 seconds + 500ms per move. The PSTs don't "have" to be static but that was the first thing I've tried. Before that I was only counting material, when I tried PSTs the playing strength improved massively and I thought that meant the evaluation was doing it's job. I have to admit that I don't really understand everything you said above. The only conclusion I'm ready to make at this point is that I need to study this topic more. Like actually reading books on chess. :P

If you have any tips regarding where to start reading let me know. (You mentioned mobility for example)
I would download the latest Crafty and just read all the comments. Bob explains everything and why. It was 17 years ago that I read it and all I remember is that it was very helpful!