GediminasMasaitis / chess-dot-cpp

GNU General Public License v3.0
17 stars 3 forks source link

mysterious ds command #2

Open tissatussa opened 1 year ago

tissatussa commented 1 year ago

lately i stumbled upon your chess engine project and i found the intriguing option 'ds' .. my attention was triggered by the info of the help command :

ds [nodes=1000000]:
"Display search".
Similar to "d", but runs a search for each piece being removed,
giving a representation of the search's perceived worth of each piece in the loaded position.

here's the output of a typical Kings Gambit opening position :

uci
ucinewgame
position startpos moves e2e4 e7e5 f2f4 e5f4 g1f3
isready
readyok
ds
Initial search... Score: -69, g7g5 f1c4 b8c6 h2h4 g5g4 f3g5 c6e5 c4b3 h7h6 d2d4 h6g5 d4e5 d7d6 b1c3 f8g7 e5d6
Searching without R a1... Piece value: 270, g8f6 e4e5 f6g4 d2d4 d7d6 f1d3 d6e5 e1g1 b8c6 d4e5 f8c5 g1h1 c5e3 d1e1 e3c1
Searching without N b1... Piece value: 341, f8e7 d2d4 e7h4 e1e2 d7d6 c1f4 h4e7 e2e1 g8f6 f1d3 e8g8 c2c3 b8d7 e4e5 f6d5 f4g3 d6e5 d4e5 d7c5
Searching without B c1... Piece value: 407, d7d5 e4d5 g8f6 f1b5 c7c6 d5c6 b8c6 d2d4 f8d6 e1g1 e8g8 g1h1 c8g4 b5a4 a8c8 c2c4 g4f3 g2f3
Searching without Q d1... Piece value: 945, g8f6 b1c3 d7d5 e4e5 f6e4 f1d3 c8g4 c3e4 g4f3 g2f3 d5e4 d3e4 b8c6 c2c3 d8h4 e1d1 e8c8 d2d4
Searching without B f1... Piece value: 347, d7d6 d2d4 g8f6 d1e2 f8e7 c1f4 e8g8 b1c3 f8e8 e1c1 e7f8 e4e5 b8d7 e2f1 f6h5 g2g3 c7c6
Searching without R h1... Piece value: 247, g8f6 b1c3 f8b4 d1e2 b8c6 c3d5 b4e7 e1f2 d7d6 d5f4 c8g4 c2c3 g4f3 g2f3
Searching without P a2... Piece value: 18, g8f6 e4e5 f6h5 d2d4 d7d6 d1e2 d6d5 e2f2 f8e7 f1e2 e8g8 e1g1 b8c6 b1c3 c8g4 e2d1 f8e8 g1h1
Searching without P b2... Piece value: 74, f8e7 f1e2 d7d5 e4d5 g8f6 e1g1 e8g8 b1c3 c7c6 d5c6 b8c6 g1h1 e7b4 f3g5 b4c3 d2c3
Searching without P c2... Piece value: 61, d7d5 e4d5 g8f6 f1c4 c7c6 d5c6 b8c6 b1c3 f8d6 e1g1 e8g8 d2d4 c6a5 c4e2 a5c6 f3e1 c8e6
Searching without P d2... Piece value: 52, f8b4 c2c3 b4c5 c1f4 d7d6 b1d2 g8f6 d1c2 e8g8 h2h3 f8e8 e1c1 c8e6 c1b1 b8d7
Searching without P g2... Piece value: 102, g7g5 h1g1 h7h6 b1c3 b8c6 d2d4 d7d6 f1b5 a7a6 b5a4 c8d7 d1e2 g8e7 c1d2 g5g4 a4c6 e7c6
Searching without P h2... Piece value: 59, g7g5 f1c4 d7d6 d2d4 h7h6 b1c3 f8g7 d1d3 g8f6 c1d2 b8c6 e1c1 e8g8 d1f1 c8g4 c3d5 f8e8
Searching without N f3... Piece value: 655, d8h4 g2g3 f4g3 f1g2 g3h2 e1f1 f8c5 d1f3 g8f6 b2b4 f6h5 g2h3 c5d6 b1c3 b8c6 c3b5 d6e5 d2d3 h5g3 f1g2 g3h1 g2h1 a8b8
Searching without P e4... Piece value: 127, d7d5 d2d4 f8d6 c2c4 c7c6 f1d3 d5c4 d3c4 g8e7 e1g1 e8g8 b1c3 c8g4 c1d2 e7f5 d1b1 f8e8
Searching without p f4... Piece value: -132, f8e7 d2d4 d7d6 f1d3 g8f6 e1g1 e8g8 d1e1 c7c5 e4e5 f6e8 b1c3 c5d4 e1e4 g7g6 c3d5 b8c6 d5e7 d8e7
Searching without p a7... Piece value: -48, g7g5 f1c4 g5g4 f3e5 d8h4 e1f1 g8f6 b1c3 b8c6 c4f7 e8d8 d2d4 f8h6 e5c6 d7c6 e4e5 f6h5 f1g1 c8f5 f7h5
Searching without p b7... Piece value: -137, f8e7 f1e2 e7h4 e1f1 d7d5 e4e5 d5d4 d2d3 b8c6 c1f4 a8b8 b2b3 g7g5 f4c1 g5g4 f3h4 d8h4
Searching without p c7... Piece value: -150, g7g5 h2h4 g5g4 f3e5 d8e7 d2d4 d7d6 f1b5 e8d8 c1f4 d6e5 d4e5 c8d7 b1c3 e7c5 d1d3 d8e8 e1c1 c5b6 f4g3
Searching without p d7... Piece value: -37, g7g5 h2h3 g8f6 b1c3 f6h5 h1g1 f8g7 d2d4 h5g3 e4e5 b8c6 f1b5 e8g8 c3e2 g3e2 b5e2 f8e8
Searching without p f7... Piece value: -157, g7g5 h2h3 g8f6 b1c3 f6h5 f3d4 h5g7 f1c4 d7d6 d4f3 b8d7 d2d4 c7c6 d1e2 d8e7 c1d2 d7b6
Searching without p g7... Piece value: -185, d7d5 e4d5 g8e7 b1c3 f8h6 f1c4 e8g8 e1g1 b8d7 d2d4 d7f6 c4b3 e7g6 h2h3 f8e8
Searching without p h7... Piece value: 23, g7g5 d1e2 b8c6 e1d1 d7d6 c2c3 d8e7 d2d4 c8g4 e2b5 e8c8 d1c2 e7e4 f1d3 e4e6 f3g5 e6f6 b1d2 d8e8
Searching without r a8... Piece value: -227, f8e7 g2g3 f4g3 h2g3 d7d5 e4e5 e8f8 d2d4 b8c6 b1c3 c8g4 f1g2 h7h5 c3e2 h5h4 c2c3
Searching without n b8... Piece value: -358, g7g5 d1e2 g5g4 f3d4 d8h4 e1d1 g8e7 e2e1 h4e1 d1e1 d7d5 d2d3 f8g7 d4e2 f4f3 g2f3
Searching without b c8... Piece value: -398, g7g5 d2d4 g5g4 c1f4 g4f3 d1f3 b8c6 c2c3 d8e7 b1d2 e8c8 f1c4 f8h6 e1g1 c8b8 a1e1 h6f4
Searching without q d8... Piece value: -1027, h7h6 b1c3 g7g5 d2d4 g8f6 e4e5 f6h5 c1d2 f8e7 f1d3 d7d6 c3d5 e7d8 e5d6 c7d6 d1e2 c8e6 e1c1 e8g8
Searching without b f8... Piece value: -473, g7g5 d1e2 g5g4 f3g1 d8h4 e1d1 b8c6 e2e1 h4e1 d1e1 d7d5 e4d5 c6b4 b1a3 g8f6 d2d3 e8g8 c1f4 f8e8 g1e2
Searching without n g8... Piece value: -346, g7g5 h2h3 f8g7 d2d4 e8g8 b1c3 d7d5 e4d5 f8e8 f1e2 c7c6 e1g1 c6d5 g1h1 b8c6 a2a3 h7h6 d1d3 c8e6
Searching without r h8... Piece value: -170, f8e7 g2g3 g8f6 b1c3 e8g8 d1e2 d7d5 e4e5 f8e8 e2g2 f6e4 d2d3 e4c3 b2c3 f4g3
+-------+-------+-------+-------+-------+-------+-------+-------+
|   r   |   n   |   b   |   q   |   k   |   b   |   n   |   r   |
| -227  | -358  | -398  | -1027 |   0   | -473  | -346  | -170  | 8
|       |       |       |       |       |       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   p   |   p   |   p   |   p   |       |   p   |   p   |   p   |
|  -48  | -137  | -150  |  -37  |       | -157  | -185  |  23   | 7
|       |       |       |       |       |       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       | 6
|       |       |       |       |       |       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       | 5
|       |       |       |       |       |       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |       |       |   P   |   p   |       |       |
|       |       |       |       |  127  | -132  |       |       | 4
|       |       |       |       |       |       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |       |       |       |   N   |       |       |
|       |       |       |       |       |  655  |       |       | 3
|       |       |       |       |       |       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   P   |   P   |   P   |   P   |       |       |   P   |   P   |
|  18   |  74   |  61   |  52   |       |       |  102  |  59   | 2
|       |       |       |       |       |       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   R   |   N   |   B   |   Q   |   K   |   B   |       |   R   |
|  270  |  341  |  407  |  945  |   0   |  347  |       |  247  | 1
|       |       |       |       |       |       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
    A       B       C       D       E       F       G       H   
Side: Black
FEN: rnbqkbnr/pppp1ppp/8/8/4Pp2/5N2/PPPP2PP/RNBQKB1R b KQkq -
Key: 10467654713723695598
Eval: -33
Search: -69
Phase: 24

the statistics below the diagram are same as with the 'd' command, except the 'Search' value.

all this output is rather mysterious to me .. maybe this ds command is just for private testing .. anyhow, i like it, but i don't understand yet .. the idea "run-a-search-for-each-piece-being-removed" is a nifty concept .. i once thought about it too, being curious what the outcome will be, 'cause there must be logic in it .. eg. those (changed) values could fit some 64-magic-square configuration or some other logical count mechanism, involving the movement rules and .. best move(s) !?

i hope you get my picture.

can you paint yours ? could you explain some more about "the search's perceived worth of each piece" ? did you implement this function in any way ? what is meant by 'Piece value' ? is the 'worth' like a 'static evaluation' value ? what is 'Phase' ? btw. i can not change the value -69, eg. when i run 'ds nodes=50000000' or so ..

the game of chess is wonderful for programmers and their logic, 'cause we have mate-in-# and many designed test positions !? i've always wanted to meet some programmer thinking outside the box, with time and passion to explore new grounds in logic. myself, i did many experiments with ideas regarding "managing chess values", nothing serious yet though, and only Python and JS) ..

i await your feedback, i'm really curious !

GediminasMasaitis commented 1 year ago

Sorry for the long response, I'm glad you like it!

can you paint yours ? could you explain some more about "the search's perceived worth of each piece" ? did you implement this function in any way ? what is meant by 'Piece value' ? is the 'worth' like a 'static evaluation' value ?

The way this works is for the position I run search up to some nodes. Then iteratively I remove each piece (except the king), and run search again, and compare the score to the original score of the position. The difference of these search results is what I called "search's perceived worth of each piece", but maybe that's not accurate.

btw. i can not change the value -69, eg. when i run 'ds nodes=50000000' or so .. Ah probably bad documentation. The way you would do this is ds 50000000.

Let me know if you have more questions about this. It's honestly just something I did on a whim.

tissatussa commented 1 year ago

did you implement this function in any way ? maybe this ds command is just for private testing

just curious ..

i will test ds 50000000 later.

tissatussa commented 1 year ago

.. I'm glad you like it!

i like to think out-of-the-box .. many chess engine programmers follow the well-known methods and steps to create some own engine, but i noticed many aren't good at playing chess in practice .. it seems in general they are mainly focussed on statistics of self-play-games while adjusting their parameters .. i want to elaborate on this .. concerning all this, today i posted some bug at https://github.com/scs-ben/pygone/issues/4 , adding some interesting questions about engine design, esp. time management .. can you scetch your view ?

GediminasMasaitis commented 1 year ago

today i posted some bug at https://github.com/scs-ben/pygone/issues/4 , adding some interesting questions about engine design, esp. time management .. can you scetch your view ?

I was too late, and I think you were as well with this comment, that issue seems to be resolved