==================================
Everybody is now either talking about neural nets
or doing just material and piece square table evaluation.
I did something completely different during the last lockdown weeks.
I implemented an alternative evaluation in C++ in my private engine Elephant 1.9.
That means I implemented the complete evaluation from the book
"The Secret of Chess" by Lyudmil Tsvetkov (2017).
This can either replace my own evaluation in the normal engine play
or it is just used as a position evaluation in a test mode with detailed logging.
The switch is made with some macros. Deactivated the whole logging code is gone.
The book has about 7 or 8 main chapters or topics and about
292 evaluation patterns or features and lots of piece square tables.
In my C++ source that is written in
7536 (eval) + 2320 (pawn eval) + 2231 (psqt) + 744 (logging) = 12831 lines of code.
That looks like this
Code: Select all
case WKnight:
{
BB tt = attacks[sq];
while (tt)
{
SquareType to = msb_nr(tt);
PieceType to_piece = board[to];
if (to_piece == NoPiece && !(attackers[to] & pos.bitboard_[Black][Pawn]))
{
mobility_value[White] += psqt.get_mobility_psq(White, Knight, to);
LOG_EVAL_FEATURE_SQ_PC_TO(EvalTopicMobility, "Mobility piece square table", White, sq, piece, to, psqt.get_mobility_psq(White, Knight, to))
++mobility_num;
}
...
I had to make a few tiny changes and own decisions compared to the raw TSoC
because not all definitions were absolutely clear or the implementation would be too arkward.
There may still exist some bugs in my implementation. I could not test all of it by now.
My engine itself is not very strong. I think there are some bugs in the search,
qsearch, SEE implementation and the performance (NPS) is not very good.
With the TSoC evaluation activated (no logging) the NPS and search depth goes down a lot
and with an interesting playing style it most often loses against FairyMax in Winboard.
When I scale down every non-material positional evaluation by 50% my engine has more wins
than losses and some of the games look spectacular.
Therefore the test and logging variant for one position only is more interesting.
Here is an example taken from a gm2600 position:
Test evaluation for FEN/EPD 8/p5p1/1pnnkp2/4p2p/4P3/P2K1P2/1PN3PP/4B3 b - - 0 37 [0.5]
[d]8/p5p1/1pnnkp2/4p2p/4P3/P2K1P2/1PN3PP/4B3 b - - 0 37
Code: Select all
+-----------------+
8 | . . . . . . . . | (Black)
7 | o . . . . . o . |
6 | . o n n k o . . |
5 | . . . . o . . o | (M50=0)
4 | . . . . P . . . | (M=37)
3 | P . . K . P . . |
2 | . P N . . . P P |
1 | . . . . B . . . |
+-----------------+
a b c d e f g h
Topic Side Midgame Endgame
material_value White 1200 1260
material_value Black 1190 1230
psqt_value White 71 162
psqt_value Black 120 237
corr_piece_value White -14 -35
corr_piece_value Black 20 20
pawn_value White 61 24
pawn_value Black 57 19
pawn_piece_value White 69 36
pawn_piece_value Black 53 28
mobility_value White 163 173
mobility_value Black 197 208
outpost_value White 12 0
outpost_value Black 32 6
imbalance_value White 0 0
imbalance_value Black -10 -30
king_safety_value White 4 32
king_safety_value Black 110 48
piece_activity_value White 32 15
piece_activity_value Black 15 5
total_value White 1598 1667
total_value Black 1784 1771
total_value combined (W-B) -186 -104
total_score -121 for interpolation_permille 797
final_score (scaled) -121
Bitboards and infos from the pawn evaluation
half open files (White) 3030303030303030 (Black) 3030303030303030 (open) 3030303030303030
passed pawns (White) 0000000000000000 (Black) 0000000000000000
isolated pawns (White) 0000000000000000 (Black) 0000000000000000
backward pawns (White) 0000000000000000 (Black) 0000000000000000
doubled pawns (White) 0000000000000000 (Black) 0000000000000000
ram pawns (White) 0000000008000000 (Black) 0000000800000000
closing pawns (White) 0000000000000000 (Black) 0000000000000000
Score 121
Collected Evaluation (midgame to endgame interpolation 797/1000):
Evaluation Topic, Feature, Side, Square, To, Piece, Score
EvalTopicMaterial , Piece values, White, e4, , P, 103
EvalTopicMaterial , Piece values, White, a3, , P, 103
EvalTopicMaterial , Piece values, White, f3, , P, 103
EvalTopicMaterial , Piece values, White, b2, , P, 103
EvalTopicMaterial , Piece values, White, g2, , P, 103
EvalTopicMaterial , Piece values, White, h2, , P, 103
EvalTopicMaterial , Piece values, White, c2, , N, 302
EvalTopicMaterial , Piece values, White, e1, , B, 328
EvalTopicMaterial , Piece values, Black, a7, , P, 103
EvalTopicMaterial , Piece values, Black, g7, , P, 103
EvalTopicMaterial , Piece values, Black, b6, , P, 103
EvalTopicMaterial , Piece values, Black, f6, , P, 103
EvalTopicMaterial , Piece values, Black, e5, , P, 103
EvalTopicMaterial , Piece values, Black, h5, , P, 103
EvalTopicMaterial , Piece values, Black, c6, , N, 302
EvalTopicMaterial , Piece values, Black, d6, , N, 302
EvalTopicPieceSquareTable, Piece square table, White, e4, , P, 53
EvalTopicPieceSquareTable, Piece square table, White, a3, , P, 9
EvalTopicPieceSquareTable, Piece square table, White, d3, , K, 28
EvalTopicPieceSquareTable, Piece square table, White, f3, , P, 19
EvalTopicPieceSquareTable, Piece square table, White, b2, , P, 9
EvalTopicPieceSquareTable, Piece square table, White, g2, , P, 9
EvalTopicPieceSquareTable, Piece square table, White, h2, , P, 7
EvalTopicPieceSquareTable, Piece square table, White, e1, , B, 9
EvalTopicPieceSquareTable, Piece square table, Black, a7, , P, 7
EvalTopicPieceSquareTable, Piece square table, Black, g7, , P, 9
EvalTopicPieceSquareTable, Piece square table, Black, b6, , P, 14
EvalTopicPieceSquareTable, Piece square table, Black, c6, , N, 28
EvalTopicPieceSquareTable, Piece square table, Black, d6, , N, 37
EvalTopicPieceSquareTable, Piece square table, Black, e6, , K, 28
EvalTopicPieceSquareTable, Piece square table, Black, f6, , P, 19
EvalTopicPieceSquareTable, Piece square table, Black, e5, , P, 53
EvalTopicPieceSquareTable, Piece square table, Black, h5, , P, 19
EvalTopicPawnsOnly , Defended pawns, White, e4, , P, 10
EvalTopicPawnsOnly , Defended pawns, White, a3, , P, 2
EvalTopicPawnsOnly , Defended pawns, White, f3, , P, 4
EvalTopicPawnsOnly , Long chain pawns, White, f3, , P, 3
EvalTopicPawnsOnly , Weak spot, White, b3, , ., -2
EvalTopicPawnsOnly , Aligned pawns, White, g2, , P, 3
EvalTopicPawnsOnly , Defending aligned pawns, White, g2, , P, 1
EvalTopicPawnsOnly , Aligned pawns, White, h2, , P, 2
EvalTopicPawnsOnly , Weak spot, Black, a6, , ., -2
EvalTopicPawnsOnly , Weak spot, Black, g6, , ., -2
EvalTopicPawnsOnly , Defended pawns, Black, b6, , P, 3
EvalTopicPawnsOnly , Defended pawns, Black, f6, , P, 4
EvalTopicPawnsOnly , Long chain pawns, Black, f6, , P, 3
EvalTopicPawnsOnly , Defended pawns, Black, e5, , P, 10
EvalTopicPawnsOnly , Verticaly isolated pawns, Black, h5, , P, -10
EvalTopicPawnsOnly , Central bind, White, , , P, 8
EvalTopicPawnsOnly , Central bind, Black, , , P, 8
EvalTopicPawnsOnly , Space advantage on both sides, Black, , , P, 12
EvalTopicCorrPieceValues , Pawns on own bishop color squares, White, a3, , P, -14
EvalTopicCorrPieceValues , Pawns on own bishop color squares, White, b2, , P, -14
EvalTopicCorrPieceValues , Pawns on own bishop color squares, White, h2, , P, -14
EvalTopicCorrPieceValues , Knights with blocked pawns, White, c2, , N, 10
EvalTopicCorrPieceValues , Knights with blocked pawns, Black, c6, , N, 10
EvalTopicCorrPieceValues , Knights with blocked pawns, Black, d6, , N, 10
EvalTopicMobility , Mobility piece square table, Black, c6, b8, N, 11
EvalTopicMobility , Mobility piece square table, Black, c6, d8, N, 13
EvalTopicMobility , Mobility piece square table, Black, c6, e7, N, 15
EvalTopicMobility , Mobility piece square table, Black, c6, a5, N, 16
EvalTopicMobility , Mobility piece square table, Black, c6, d4, N, 30
EvalTopicMobility , Mobility piece square table, Black, d6, c8, N, 12
EvalTopicMobility , Mobility piece square table, Black, d6, e8, N, 13
EvalTopicMobility , Mobility piece square table, Black, d6, b7, N, 13
EvalTopicMobility , Mobility piece square table, Black, d6, f7, N, 14
EvalTopicMobility , Mobility piece square table, Black, d6, b5, N, 24
EvalTopicMobility , Mobility piece square table, Black, d6, c4, N, 28
EvalTopicMobility , Mobility piece square table, Black, e6, d7, K, 4
EvalTopicMobility , Mobility piece square table, Black, e6, e7, K, 4
EvalTopicMobility , Mobility piece square table, Black, e6, f7, K, 4
EvalTopicMobility , Mobility piece square table, Black, h5, h4, P, 4
EvalTopicMobility , Mobility piece square table, White, d3, c3, K, 4
EvalTopicMobility , Mobility piece square table, White, d3, e3, K, 4
EvalTopicMobility , Mobility piece square table, White, d3, d2, K, 4
EvalTopicMobility , Mobility piece square table, White, d3, e2, K, 4
EvalTopicMobility , Mobility piece square table, White, c2, b4, N, 24
EvalTopicMobility , Mobility piece square table, White, c2, e3, N, 24
EvalTopicMobility , Mobility piece square table, White, c2, a1, N, 10
EvalTopicMobility , Mobility piece square table, White, e1, b4, B, 21
EvalTopicMobility , Mobility piece square table, White, e1, h4, B, 14
EvalTopicMobility , Mobility piece square table, White, e1, c3, B, 18
EvalTopicMobility , Mobility piece square table, White, e1, g3, B, 17
EvalTopicMobility , Mobility piece square table, White, e1, d2, B, 13
EvalTopicMobility , Mobility piece square table, White, e1, f2, B, 12
EvalTopicPawnsAndPieces , Central piece attack, White, c6, , ., 9
EvalTopicPawnsAndPieces , Central piece attack, White, e6, , ., 9
EvalTopicPawnsAndPieces , Central piece attack, White, f6, , ., 9
EvalTopicPawnsAndPieces , Extended central piece attack, White, e6, , ., 5
EvalTopicPawnsAndPieces , Extended central piece attack, White, g7, , ., 5
EvalTopicPawnsAndPieces , Extended central piece attack, White, e6, , ., 5
EvalTopicPawnsAndPieces , Central piece attack, Black, d6, , ., 9
EvalTopicPawnsAndPieces , Central piece attack, Black, d3, , ., 9
EvalTopicPawnsAndPieces , Central piece attack, Black, f3, , ., 9
EvalTopicPawnsAndPieces , Extended central piece attack, Black, g2, , ., 5
EvalTopicOutposts , Minor piece diagonally behind own pawn, Black, d6, , N, 4
EvalTopicOutposts , Minor piece near own pawn on same rank, Black, d6, , N, 4
EvalTopicOutposts , Penetration point, White, d5, , ., 1
EvalTopicOutposts , Penetration point, White, f5, , ., 1
EvalTopicOutposts , Penetration point, Black, d4, , ., 1
EvalTopicOutposts , Penetration point, Black, f4, , ., 1
EvalTopicImbalances , Knight pair, Black, , , ., -26
EvalTopicKingSafety , No pawn shelter, White, , , ., -14
EvalTopicKingSafety , No pawn on 2nd rank in king shelter, Black, , , ., -4
EvalTopicKingSafety , Knight attacking king shelter, Black, c6, , N, 14
EvalTopicKingSafety , Knight on king side, Black, c6, , N, 2
EvalTopicKingSafety , Minor piece defending king shelter, Black, c6, , N, 1
EvalTopicKingSafety , Knight attacking king shelter, Black, d6, , N, 14
EvalTopicKingSafety , Knight on king side, Black, d6, , N, 2
EvalTopicKingSafety , Minor piece king shelter, Black, d6, , N, 9
EvalTopicKingSafety , Pawn in king shelter, Black, f6, , P, 18
EvalTopicKingSafety , Blocked storming pawn kingside, White, e4, , P, 14
EvalTopicKingSafety , King in center sheltered by defended pawn, White, d3, , K, 1
EvalTopicKingSafety , Knight attacking king shelter, White, c2, , N, 14
EvalTopicKingSafety , Minor piece king shelter, White, c2, , N, 9
EvalTopicKingSafety , Bishop on king side, White, e1, , B, 1
EvalTopicKingSafety , Minor piece defending king shelter, White, e1, , B, 1
EvalTopicKingSafety , Two semi open files near opp king, Black, , , ., 6
EvalTopicPieceActivity , Defending pawns, Black, a7, , P, 5
EvalTopicPieceActivity , Preventing opp minor penetration, Black, b6, , P, 1
EvalTopicPieceActivity , Potential checks, Black, c6, , N, 9
EvalTopicPieceActivity , Undefended pieces, Black, c6, , N, -11
EvalTopicPieceActivity , Direct Attacks, Black, d6, , N, 8
EvalTopicPieceActivity , Knight attacking opp defended pawn, Black, d6, , N, -4
EvalTopicPieceActivity , Hanging pawn, White, e4, , P, -2
EvalTopicPieceActivity , Preventing opp minor penetration, White, a3, , P, 1
EvalTopicPieceActivity , Potential checks, White, c2, , N, 9
EvalTopicPieceActivity , Piece defence, White, e1, , B, 11
Evaluation based on topics (midgame to endgame interpolation 797/1000):
Evaluation Topic , White score, Black score, Total score (seen from White)
EvalTopicMaterial , 1248, 1222, 26
EvalTopicPieceSquareTable, 144, 213, -69
EvalTopicCorrPieceValues , -31, 20, -51
EvalTopicPawnsOnly , 32, 27, 5
EvalTopicPawnsAndPieces , 43, 33, 10
EvalTopicMobility , 171, 206, -35
EvalTopicOutposts , 2, 11, -9
EvalTopicImbalances , 0, -26, 26
EvalTopicKingSafety , 26, 63, -37
EvalTopicPieceActivity , 18, 7, 11
EvalTopicTotalValue , 1653, 1776, -123
No scaling occured
Evaluation for squares (White):
+----------+----------+----------+----------+----------+----------+----------+----------+
8 | . 0 | . 0 | . 0 | . 0 | . 0 | . 0 | . 0 | . 0 |
+----------+----------+----------+----------+----------+----------+----------+----------+
7 | p 0 | . 0 | . 0 | . 0 | . 0 | . 0 | p 5 | . 0 |
+----------+----------+----------+----------+----------+----------+----------+----------+
6 | . 0 | p 0 | n 9 | n 0 | k 19 | p 9 | . 0 | . 0 |
+----------+----------+----------+----------+----------+----------+----------+----------+
5 | . 0 | . 0 | . 0 | . 1 | p 0 | . 1 | . 0 | p 0 |
+----------+----------+----------+----------+----------+----------+----------+----------+
4 | . 0 | . 0 | . 0 | . 0 | P 178 | . 0 | . 0 | . 0 |
+----------+----------+----------+----------+----------+----------+----------+----------+
3 | P 102 | . -2 | . 0 | K 47 | . 0 | P 129 | . 0 | . 0 |
+----------+----------+----------+----------+----------+----------+----------+----------+
2 | . 0 | P 99 | N 402 | . 0 | . 0 | . 0 | P 117 | P 98 |
+----------+----------+----------+----------+----------+----------+----------+----------+
1 | . 0 | . 0 | . 0 | . 0 | B 446 | . 0 | . 0 | . 0 |
+----------+----------+----------+----------+----------+----------+----------+----------+
A B C D E F G H
Evaluation for squares (Black):
+----------+----------+----------+----------+----------+----------+----------+----------+
8 | . 0 | . 0 | . 0 | . 0 | . 0 | . 0 | . 0 | . 0 |
+----------+----------+----------+----------+----------+----------+----------+----------+
7 | p 115 | . 0 | . 0 | . 0 | . 0 | . 0 | p 112 | . 0 |
+----------+----------+----------+----------+----------+----------+----------+----------+
6 | . -2 | p 121 | n 440 | n 500 | k 41 | p 147 | . -2 | . 0 |
+----------+----------+----------+----------+----------+----------+----------+----------+
5 | . 0 | . 0 | . 0 | . 0 | p 166 | . 0 | . 0 | p 115 |
+----------+----------+----------+----------+----------+----------+----------+----------+
4 | . 0 | . 0 | . 0 | . 1 | P 0 | . 1 | . 0 | . 0 |
+----------+----------+----------+----------+----------+----------+----------+----------+
3 | P 0 | . 0 | . 0 | K 9 | . 0 | P 9 | . 0 | . 0 |
+----------+----------+----------+----------+----------+----------+----------+----------+
2 | . 0 | P 0 | N 0 | . 0 | . 0 | . 0 | P 5 | P 0 |
+----------+----------+----------+----------+----------+----------+----------+----------+
1 | . 0 | . 0 | . 0 | . 0 | B 0 | . 0 | . 0 | . 0 |
+----------+----------+----------+----------+----------+----------+----------+----------+
A B C D E F G H
Used evaluation feature count:
EvalTopicMaterial , Piece values, 16
EvalTopicPieceSquareTable, Piece square table, 18
EvalTopicCorrPieceValues , Knights with blocked pawns, 12
EvalTopicCorrPieceValues , Pawns on own bishop color squares, 3
EvalTopicPawnsOnly , Aligned pawns, 2
EvalTopicPawnsOnly , Central bind, 2
EvalTopicPawnsOnly , Defended pawns, 6
EvalTopicPawnsOnly , Defending aligned pawns, 1
EvalTopicPawnsOnly , Distant neighbour pawns, 2
EvalTopicPawnsOnly , Long chain pawns, 2
EvalTopicPawnsOnly , Ram pawns, 2
EvalTopicPawnsOnly , Space advantage on both sides, 1
EvalTopicPawnsOnly , Symmetrical aligned pawns, 4
EvalTopicPawnsOnly , Verticaly isolated pawns, 1
EvalTopicPawnsOnly , Weak spot, 3
EvalTopicPawnsAndPieces , Central piece attack, 6
EvalTopicPawnsAndPieces , Extended central piece attack, 4
EvalTopicMobility , Mobility piece square table, 37
EvalTopicOutposts , Minor piece diagonally behind own pawn, 1
EvalTopicOutposts , Minor piece near own pawn on same rank, 1
EvalTopicOutposts , Penetration point, 4
EvalTopicImbalances , Knight pair, 1
EvalTopicKingSafety , Bishop on king side, 1
EvalTopicKingSafety , Blocked storming pawn kingside, 1
EvalTopicKingSafety , King in center sheltered by defended pawn, 1
EvalTopicKingSafety , Knight attacking king shelter, 3
EvalTopicKingSafety , Knight on king side, 2
EvalTopicKingSafety , Minor piece defending king shelter, 2
EvalTopicKingSafety , Minor piece king shelter, 2
EvalTopicKingSafety , No pawn on 2nd rank in king shelter, 1
EvalTopicKingSafety , No pawn shelter, 1
EvalTopicKingSafety , Pawn in king shelter, 1
EvalTopicKingSafety , Two semi open files near opp king, 1
EvalTopicPieceActivity , Bishop attacking opp defended pawn, 1
EvalTopicPieceActivity , Defending pawns, 18
EvalTopicPieceActivity , Direct Attacks, 74
EvalTopicPieceActivity , Hanging pawn, 1
EvalTopicPieceActivity , Knight attacking opp defended pawn, 3
EvalTopicPieceActivity , Piece defence, 16
EvalTopicPieceActivity , Potential checks, 4
EvalTopicPieceActivity , Potential discovered checks, 1
EvalTopicPieceActivity , Preventing opp minor penetration, 2
EvalTopicPieceActivity , Queen and bishop battery, 1
EvalTopicPieceActivity , Undefended pieces, 1
EvalTopicPieceActivity , X-ray attacks, 10
EvalTopicPieceActivity , X-ray past three pieces attacks, 5
EvalTopicPieceActivity , X-ray past two pieces attacks, 5