Uri Blass wrote:It is possible to build a book based on fixed depth analysis(or fixed time analysis) or other ideas that may be better.
Maybe get an estimate for probability for every line based on the evaluations and continue next with the best probability is better than what I did in this example but calculating probability for every move manually if we assume that the probability is proportional to some function of the evaluation function is something that I cannot demonstrate easily and is suitable more for computers and I made manually the example to demonstrate what I mean.
I give an example by fixed depth that is not the best.
Here is one idea that is not the best to build a book for 1+1 time control game but is probably better than the empty book because black put moves in the book for black at bigger depths than the depth that it practically reach at 1+1 and stockfish does not get depth 30 in the opening in 1+1 time control.
The variables here are
1)20(depth analysis for white that is important only to choose the positions to add moves for black so quality of moves is relatively less important)
2)30(depth analysis for black and moves that I add for book of black are analyzed at depth 30
3)0.1 number that encourage the program to prefer short lines in the book relative to long lines(I prefer to analyze more options and not to go forward in the analysis as long as there are alternatives that are less than 0.1 pawn weaker than the best move).
To build a book for black
I start by analyzing the opening position at depth 20
I get the following analysis:
[D]rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
Stockfish_18022413_x64_modern:
20/31 00:40 111,989k 2,762k -0.69 1.f3 e5 2.e3 d5 3.d4 exd4 4.exd4 Bd6 5.Nc3 c6 6.g3 Ne7 7.Bg2 h5 8.f4 Bg4 9.Nge2 h4 10.h3 Bxe2 11.Qxe2 hxg3 12.Bd2
20/31 00:40 111,989k 2,762k -0.61 1.g4 d5 2.Bg2 Bxg4 3.c4 Nf6 4.h3 Bd7 5.cxd5 c6 6.dxc6 Bxc6 7.Nf3 e6 8.Nc3 Nbd7 9.d3 Bb4 10.0-0 0-0 11.Bd2 Kh8 12.Kh1
20/31 00:40 111,989k 2,762k -0.44 1.Nh3 e5 2.c3 d5 3.d4 Nc6 4.dxe5 Nxe5 5.Bf4 Ng6 6.Bg3 c6 7.e3 Nf6 8.Bd3 Bd6 9.Ng5 Ne5 10.Bxe5 Bxe5 11.Nd2 h6 12.Ngf3 Bd6
20/24 00:40 111,989k 2,762k -0.36 1.b4 d5 2.Nf3 Nf6 3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c5
20/28 00:40 111,989k 2,762k +0.39 1.d4 d5 2.Nf3 e6 3.c4 Nf6 4.Nc3 Be7 5.Bg5 Nc6 6.e3 h6 7.Bxf6 Bxf6 8.cxd5 exd5 9.Qb3 Ne7 10.e4 dxe4 11.Nxe4 Nc6
20/35 00:40 111,989k 2,762k +0.40 1.e4 e5 2.Nf3 Nc6 3.Bb5 Nf6 4.0-0 Nxe4 5.d4 a6 6.Bxc6 dxc6 7.Re1 Nf6 8.Nxe5 Be6 9.c4 Bd6 10.Bf4 0-0 11.Qd3 Nd7 12.Nc3 Re8 13.h3 Nxe5 14.Bxe5 h6 15.Bxd6 Qxd6 16.Rad1
It means I have the following scores relative to best move
1.e4 0
1.d4 -0.01
1.e3 -0.03
1.Nf3 -0.04
1.c4 -0.08
1.Nc3 -0.17
1.b3 -0.3
1.d3 -0.3
1.h3 -0.33
1.c3 -0.35
1.a3 -0.37
1.g3 -0.40
...
I analyze after the best move 1.e4 and
I get at depth 30 the move 1...e6 and I do not use multi-pv because I want the book for black to have one option for black at every node and many options for white to be ready for many options the opponents can play.
Now the score of 1.e4 e6 is -0.1 because I have the rule that I substract 0.1 for every move of black from the score so at this point I do not analyze what happens after 1.e4 e6 but analyze what happens after 1.d4 that has a better score of -0.01 and the order of analysis is
1)opening position score multi-pv all options 0
2)best move 1.e4 0(best move at depth 30 is 1...e6 so add it to the book)
3)1.d4 -0.01(best move at depth 30 is 1...Nf6 so add it to the book)
4)1.e3 -0.03(best move at depth 30 is 1...e6 so add it to the book)
5)1.Nf3 -0.04(best move at depth 30 is 1...e6 so add it to the book)
6)1.c4 -0.08(best move at depth 30 is 1...e5 so add it to the book)
7)1.e4 e6 -0.1(all options depth 20)
2.Nc3 was the best move for white at depth 20 and here is part of the analysis with multi-pv=30
20/27 01:04 176,711k 2,735k +0.37 2.Nf3 d5 3.exd5 exd5 4.d4 Nf6 5.Bd3 Bd6 6.Qe2+ Be7 7.0-0 0-0 8.Be3 Nc6 9.c3 Re8 10.Qc2 Bd6 11.Nbd2 Bd7 12.h3 h6 13.Rae1 a6 14.Kh1 Be6 15.Nb3
20/37 01:04 176,711k 2,735k +0.39 2.d4 d5 3.Nc3 Nf6 4.Bg5 Be7 5.e5 Ne4 6.Nxe4 dxe4 7.Be3 c5 8.dxc5 Qc7 9.Qd4 Bd7 10.0-0-0 0-0 11.Qxe4 Bc6 12.Qd4 Nd7 13.Nf3 Bxc5
20/31 01:04 176,711k 2,735k +0.47 2.Nc3 d5 3.d4 Nf6 4.Bg5 Be7 5.e5 Ne4 6.Nxe4 dxe4 7.Bxe7 Qxe7 8.c3 Nd7 9.Ne2 b6 10.Ng3 Bb7 11.Bb5 0-0 12.0-0 c5 13.Re1 Rfd8 14.Nxe4 Nxe5 15.Nxc5 bxc5 16.Rxe5 cxd4
It means
1.e4 e6 2.Nc3 get a score of -0.1
1.e4 e6 2.d4 get a score of -0.18
1.e4 e6 2.Nf3 get a score of -0.2 and other lines after 1.e4 e6 get a worse score
steps to continue are
8)analyze 1.e4 e6 2.Nc3 that has -0.1 score(0 for mistakes of white and -0.1 for number of moves black already played) and find a move for black because this line has the best score
9)analyze all options for white after 1.d4 Nf6 that has -0.11 score (-0.01 for mistakes of white and -0.1 for number of moves black already played)
10)1.d4 Nf6 2.c4 is the best move for white so analyze this line that has score of -0.11 to add a move for black for the book.
Tried to create a program based on your description. Check if it is right. It searches up to 4 plies deep, no matter how low is the line score, but relative score of move is limited to a minimum of -0.10.
Code: Select all
:: Settings ::
Book for : Black
black move penalty : -0.10
minimum relative score : -0.10
Max ply : 4
movetime (ms) : 1000
engine : Stockfish 9
hash (mb) : 128
threads : 1
current pos:
[d]rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
Code: Select all
Search at multipv = 4, movetime = 16s
1. d2d4 {scorecp: 39, depth: 22, rel_score: 0.00, penalty: 0.00}
1. g1f3 {scorecp: 37, depth: 22, rel_score: -0.02, penalty: 0.00}
1. e2e4 {scorecp: 37, depth: 22, rel_score: -0.02, penalty: 0.00}
1. e2e3 {scorecp: 27, depth: 22, rel_score: -0.12, penalty: 0.00}
move to search next: 1. d2d4 {0.00}
current pos:
[d]rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR b KQkq - 0 1
Code: Select all
Search at multipv = 1, movetime = 1s
1... d7d5 {scorecp: -15, depth: 19, rel_score: 0.00, penalty: -0.10}
move to search next: 1... d7d5 {0.00}
current pos:
[d]rnbqkbnr/ppp1pppp/8/3p4/3P4/8/PPP1PPPP/RNBQKBNR w KQkq - 0 2
Code: Select all
Search at multipv = 4, movetime = 16s
2. c2c4 {scorecp: 44, depth: 21, rel_score: 0.00, penalty: 0.00}
2. g1f3 {scorecp: 42, depth: 21, rel_score: -0.02, penalty: 0.00}
2. e2e3 {scorecp: 35, depth: 21, rel_score: -0.09, penalty: 0.00}
2. c1f4 {scorecp: 26, depth: 21, rel_score: -0.18, penalty: 0.00}
move to search next: 2. c2c4 {0.00}
current pos:
[d]rnbqkbnr/ppp1pppp/8/3p4/2PP4/8/PP2PPPP/RNBQKBNR b KQkq - 0 2
Code: Select all
Search at multipv = 1, movetime = 1s
2... e7e6 {scorecp: -2, depth: 19, rel_score: 0.00, penalty: -0.10}
move to search next: 2... e7e6 {0.00}
--->>> book line: 1
1. d2d4 {rel_score: 0.00, line_score: 0.00} 1... d7d5 {rel_score: 0.00, line_score: -0.10} 2. c2c4 {rel_score: 0.00, line_score: -0.10} 2... e7e6 {rel_score: 0.00, line_score: -0.20}
move to search next: 2. g1f3 {-0.02}
current pos:
[d]rnbqkbnr/ppp1pppp/8/3p4/3P4/5N2/PPP1PPPP/RNBQKB1R b KQkq - 1 2
Code: Select all
Search at multipv = 1, movetime = 1s
2... g8f6 {scorecp: 2, depth: 17, rel_score: 0.00, penalty: -0.10}
move to search next: 2... g8f6 {0.00}
--->>> book line: 2
1. d2d4 {rel_score: 0.00, line_score: 0.00} 1... d7d5 {rel_score: 0.00, line_score: -0.10} 2. g1f3 {rel_score: -0.02, line_score: -0.12} 2... g8f6 {rel_score: 0.00, line_score: -0.22}
move to search next: 2. e2e3 {-0.09}
current pos:
[d]rnbqkbnr/ppp1pppp/8/3p4/3P4/4P3/PPP2PPP/RNBQKBNR b KQkq - 0 2
Code: Select all
Search at multipv = 1, movetime = 1s
2... g8f6 {scorecp: 3, depth: 19, rel_score: 0.00, penalty: -0.10}
move to search next: 2... g8f6 {0.00}
--->>> book line: 3
1. d2d4 {rel_score: 0.00, line_score: 0.00} 1... d7d5 {rel_score: 0.00, line_score: -0.10} 2. e2e3 {rel_score: -0.09, line_score: -0.19} 2... g8f6 {rel_score: 0.00, line_score: -0.29}
skip move: 2. c1f4, rel_score -0.18 is below -0.10
move to search next: 1. g1f3 {-0.02}
current pos:
[d]rnbqkbnr/pppppppp/8/8/8/5N2/PPPPPPPP/RNBQKB1R b KQkq - 1 1
Code: Select all
Search at multipv = 1, movetime = 1s
1... d7d5 {scorecp: -4, depth: 19, rel_score: 0.00, penalty: -0.10}
move to search next: 1... d7d5 {0.00}
current pos:
[d]rnbqkbnr/ppp1pppp/8/3p4/8/5N2/PPPPPPPP/RNBQKB1R w KQkq - 0 2
Code: Select all
Search at multipv = 4, movetime = 16s
2. d2d4 {scorecp: 55, depth: 22, rel_score: 0.00, penalty: 0.00}
2. c2c4 {scorecp: 45, depth: 22, rel_score: -0.10, penalty: 0.00}
2. e2e3 {scorecp: 30, depth: 22, rel_score: -0.25, penalty: 0.00}
2. h2h3 {scorecp: 30, depth: 22, rel_score: -0.25, penalty: 0.00}
move to search next: 2. d2d4 {0.00}
current pos:
[d]rnbqkbnr/ppp1pppp/8/3p4/3P4/5N2/PPP1PPPP/RNBQKB1R b KQkq - 0 2
Code: Select all
Search at multipv = 1, movetime = 1s
2... g8f6 {scorecp: 2, depth: 17, rel_score: 0.00, penalty: -0.10}
move to search next: 2... g8f6 {0.00}
--->>> book line: 4
1. g1f3 {rel_score: -0.02, line_score: -0.02} 1... d7d5 {rel_score: 0.00, line_score: -0.12} 2. d2d4 {rel_score: 0.00, line_score: -0.12} 2... g8f6 {rel_score: 0.00, line_score: -0.22}
skip move: 2. c2c4, rel_score -0.10 is below -0.10
skip move: 2. e2e3, rel_score -0.25 is below -0.10
skip move: 2. h2h3, rel_score -0.25 is below -0.10
move to search next: 1. e2e4 {-0.02}
current pos:
[d]rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1
Code: Select all
Search at multipv = 1, movetime = 1s
1... e7e5 {scorecp: -12, depth: 18, rel_score: 0.00, penalty: -0.10}
move to search next: 1... e7e5 {0.00}
current pos:
[d]rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2
Code: Select all
Search at multipv = 4, movetime = 16s
2. g1f3 {scorecp: 35, depth: 21, rel_score: 0.00, penalty: 0.00}
2. d2d4 {scorecp: 25, depth: 21, rel_score: -0.10, penalty: 0.00}
2. b1c3 {scorecp: 24, depth: 21, rel_score: -0.11, penalty: 0.00}
2. f1e2 {scorecp: 20, depth: 21, rel_score: -0.15, penalty: 0.00}
move to search next: 2. g1f3 {0.00}
current pos:
[d]rnbqkbnr/pppp1ppp/8/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2
Code: Select all
Search at multipv = 1, movetime = 1s
2... g8f6 {scorecp: -31, depth: 16, rel_score: 0.00, penalty: -0.10}
move to search next: 2... g8f6 {0.00}
--->>> book line: 5
1. e2e4 {rel_score: -0.02, line_score: -0.02} 1... e7e5 {rel_score: 0.00, line_score: -0.12} 2. g1f3 {rel_score: 0.00, line_score: -0.12} 2... g8f6 {rel_score: 0.00, line_score: -0.22}
move to search next: 2. d2d4 {-0.10}
current pos:
[d]rnbqkbnr/pppp1ppp/8/4p3/3PP3/8/PPP2PPP/RNBQKBNR b KQkq - 0 2
Code: Select all
Search at multipv = 1, movetime = 1s
2... e5d4 {scorecp: 21, depth: 17, rel_score: 0.00, penalty: -0.10}
move to search next: 2... e5d4 {0.00}
--->>> book line: 6
1. e2e4 {rel_score: -0.02, line_score: -0.02} 1... e7e5 {rel_score: 0.00, line_score: -0.12} 2. d2d4 {rel_score: -0.10, line_score: -0.22} 2... e5d4 {rel_score: 0.00, line_score: -0.32}
skip move: 2. b1c3, rel_score -0.11 is below -0.10
skip move: 2. f1e2, rel_score -0.15 is below -0.10
skip move: 1. e2e3, rel_score -0.12 is below -0.10