franciscoBSalgueiro / en-croissant

The Ultimate Chess Toolkit
https://encroissant.org
GNU General Public License v3.0
444 stars 51 forks source link

Game report #72

Open dav1312 opened 8 months ago

dav1312 commented 8 months ago

Issues

Suggestions

franciscoBSalgueiro commented 8 months ago

I'm having difficulty in creating decent annotations for great and brilliant moves. Your suggestion of assigning "!" to only moves that don't capture material doesn't work when, for example, you attack a queen and she only has 1 retreating square. I also can't just make it so that it doesn't apply to attacked pieces that move, because plenty of amazing moves involve moving an attacked piece to another square where it can be captured. There's also no way to distinguish attacked pieces from pieces that are attacked but very well defended.

Another example is if I move my queen to a square where a rook can technically capture it but would lead to back rank mate. Should that be brilliant?

The chess.com article doesn't give too many specifics so it's hard to know how they make the distinction.

dav1312 commented 8 months ago

I'm not sure how chess.com implemented their algorithm, I just made some assumptions based on what I've seen, I'm sorry.

I'm having difficulty in creating decent annotations for great and brilliant moves. Your suggestion of assigning "!" to only moves that don't capture material doesn't work when, for example, you attack a queen and she only has 1 retreating square. I also can't just make it so that it doesn't apply to attacked pieces that move, because plenty of amazing moves involve moving an attacked piece to another square where it can be captured. There's also no way to distinguish attacked pieces from pieces that are attacked but very well defended.

Can you send some of the examples that you mentioned? Maybe looking at them we can think on how to deal with them.

I also have some examples from games that have both great and brilliant moves according to chess.com, do you want to me to send them so you can take a look?

I'm guessing you need to have an algorithm that given a position it knows what pieces are protected to know when to give certain annotations. Arena has it, maybe you can take a look at how it works (sadly not open source). image

Another example is if I move my queen to a square where a rook can technically capture it but would lead to back rank mate. Should that be brilliant?

But the "If the played move was the best move" should take care of it for the most part right? I wouldn't expect hanging mate to be the best move. And maybe not giving brilliant moves to the player that is in a losing position after the move should help too.

The chess.com article doesn't give too many specifics so it's hard to know how they make the distinction.

They obviously don't want people to know their secrets haha

franciscoBSalgueiro commented 8 months ago

I made a lichess study with some examples of what I meant. Feel free to send your examples as well!

An algorithm to distinguish types of defended pieces could indeed help in some cases.

dav1312 commented 8 months ago

I made a lichess study with some examples of what I meant. Feel free to send your examples as well!

An algorithm to distinguish types of defended pieces could indeed help in some cases.

  1. I think it should be either "!" or "!!" since its both a sac and the only good move
  2. The queen was attacked by a lower value piece so if the best move wasn't played it wouldn't be a trade thus no great move.
  3. The queen was attacked but by another queen and it was protected by pawns so it was "safe" already since it would've been a trade, playing Qb8+ made it unsafe, making it brilliant.

    To be brilliant, the move has to lead to a position where a piece is in danger. For example, 10. Nxb5 would be brilliant too:

It seems like the algorithm to detect attacked pieces will indeed be the key for brilliant moves


Here are a couple of games with annotations

1.e4 c5 2.Bc4 d6 3.Nc3 e6 4.Nf3 a6 5.a3 b5 6.Ba2 Bb7?! 7.d4 Qc7? 8.O-O c4 9.d5
Nf6 10.dxe6 fxe6 11.Nd4 Bc8 12.Bg5 Be7 13.b3 h6 14.Be3 O-O 15.bxc4 bxc4 16.Qe2
Bd7 17.Rab1 Kh8 18.Rfd1 Nc6 19.Qxc4 Rac8 20.Nde2 Ng4 21.Bb6 Qb8! 22.Qxa6 d5!
23.Ng3? Nb4! 24.axb4 Rxc3 25.exd5 Nxf2!! 26.Bxf2 Rxf2!! 27.Ne4 Rxg2+ 28.Kxg2
Qf4!! 29.Nxc3 Qg4+! 30.Kf1 Qf4+ 31.Kg2 Qg4+! 32.Kf1 Qf4+ 33.Kg1 Qg4+! 34.Kf2
Qf4+! 35.Kg1 Qg4+! 36.Kf2 Qf4+! 37.Ke2 e5! 38.Qa8+ Kh7 39.Rg1 Bg4+! 40.Rxg4!
Qxg4+ 41.Kd3 Qd4+! 42.Ke2 Qg4+! 43.Kd3 Qd4+! 44.Ke2 Qg4+! 1/2-1/2
1.f4 d6 2.Nf3 Nc6?! 3.e4 e5 4.Bb5?! Bd7?! 5.Nc3 Qe7?! 6.O-O O-O-O 7.Nd5 Qe8
8.Bxc6?! Bxc6 9.c4 f5 10.d3! Nf6 11.Re1 Kb8 12.a4 fxe4 13.dxe4 Bd7 14.a5 c6
15.Nc3 Be7 16.Be3 Bc8?! 17.Qb3 Ng4 18.Bb6!! exf4?? 19.a6!! axb6 20.a7+ Ka8?!
21.Na4! Kxa7 22.Qxb6+ Kb8 23.Nc5!! dxc5 24.Ra8+!! Kxa8 25.Qc7! Rd1 26.Rxd1 b6
27.Ra1+ Ba6 28.Rxa6# 1-0
1.e4 c5 2.Nf3 a6 3.d4 cxd4 4.Nxd4 Nf6 5.Nc3 e5 6.Nf5? d5! 7.Ng3? Bb4? 8.Bd2? d4!
9.Nce2 Qb6 10.c3 dxc3 11.Nxc3 Bc5 12.Qe2 Bd4 13.Rc1 O-O 14.Bg5 Ng4 15.Nd5 Bxf2+
16.Kd1! Qd4+ 17.Kc2 Nc6 18.Kb1! Bxg3 19.hxg3 h6? 20.Be7! Nf2 21.Rc4! Bg4!
22.Rxh6!! Bxe2?? 23.Nf6+!! gxf6 24.Bxf6 Qd3+ 25.Rc2! Qd1+ 26.Rc1 Bd3+ 27.Bxd3
Qxd3+ 28.Ka1 Qb1+ 29.Rxb1 Nxe4 30.Rh8# 1-0
1.d4 c6 2.c4 d5 3.Nc3 f6? 4.e4?! dxe4 5.Nxe4 f5? 6.Ng5?! c5 7.N1f3 cxd4? 8.c5!
h6?! 9.Nf7!! Kxf7 10.Ne5+! Kf6 11.Qh5!! Kxe5 12.Bc4 Qa5+?! 13.Kd1?! Qxc5??
14.Bf4+!! Kxf4 15.Re1! Qxc4 16.g3#
franciscoBSalgueiro commented 7 months ago

I made a first try at assigning ! moves and it seems to work decently well. It's not distinguishing ! from !! yet though.

dav1312 commented 7 months ago

I made a first try at assigning ! moves and it seems to work decently well. It's not distinguishing ! from !! yet though.

Nice work! 😄It does seem to work fine in most cases Hopefully you can make that distinction work

dav1312 commented 7 months ago

What do you think about making reports an integral part of the live analysis? Maybe in the long term it could make the code simpler?

The report would simply automate making moves on the board forwards or backwards from where the user is in the game, using the engine settings of the first engine the user has enabled. This could mean also giving the user live analysis of the game even if its not using the automated report. And if the user stops or disables the engine, the report would stop too.

dav1312 commented 7 months ago

I rebased https://github.com/franciscoBSalgueiro/en-croissant/tree/72-game-report onto master (and changed the number of threads used in the report to 1) to test and I'm getting some weird evaluations from the report sometimes, as if it was taking the eval from the 2nd line image image

1.e4 e5 2.Nf3 Qf6 3.Bc4 Bc5 4.d3 d6 5.h3 c6 6.a3 h5 7.Nc3 Ne7 8.O-O Bg4 9.hxg4
hxg4 10.Ng5 d5 11.exd5 Qh6 12.Nh3 Qg6 13.Ne4 cxd5 14.Bb5+ Nbc6 15.Nxc5 Rxh3
16.f4 O-O-O 17.fxe5 Rh4 18.d4 g3 19.Rf4 Rdh8 20.Rxh4 Rxh4 21.Bd3 Nf5 22.Bxf5+
Qxf5 23.Be3 Qh7 24.Kf1 b6 25.Nb3 Rh1+ 26.Bg1 Rxg1+ 27.Kxg1 Nxe5 28.dxe5 Qh2+
29.Kf1 Qh1+ 30.Ke2 Qxg2+ 31.Kd3 Qe4+ 32.Kc3 Qc4+ 33.Kd2 Qf4+ 34.Kc3 Qc4+ 35.Kd2
Qf4+ 36.Kc3 Qc4+ 1/2-1/2

Or, in this other game, the report took the eval sometimes from the first line, sometimes second, and sometimes neither? I used Nibbler to compare

image image
image image
image image
1.e4 c5 2.c3 Nc6 3.d4 cxd4 4.cxd4 e6 5.Nf3 Nf6 6.Nc3 Be7 7.h3 O-O 8.Bd3 d5 9.e5
Nd7 10.h4 f6 11.Ng5 fxg5 12.Bxh7+ Kxh7 13.hxg5+ Kg8 14.Rh8+ Kxh8 15.Qh5+ Kg8
16.g6 Nf6 17.exf6 Re8 18.Qh7+ Kf8 19.Qxg7# 1-0
franciscoBSalgueiro commented 7 months ago

I think that should be fixed now

What do you think about making reports an integral part of the live analysis? Maybe in the long term it could make the code simpler?

The report would simply automate making moves on the board forwards or backwards from where the user is in the game, using the engine settings of the first engine the user has enabled. This could mean also giving the user live analysis of the game even if its not using the automated report. And if the user stops or disables the engine, the report would stop too.

Maybe that would be better, it would require some rewriting.

PaulJeFi commented 5 months ago

When generating a game report it crashes with a message "Error, no such tab : Games"