rpdelaney-archive / python-chess-annotator

Reads chess games in PGN format and adds annotations using an engine
GNU General Public License v3.0
62 stars 29 forks source link

A few questions about how this works #33

Open vesper8 opened 3 years ago

vesper8 commented 3 years ago

Hello and first of all thanks a lot for making this. I've tried several other chess analyzer tools and I managed to get none of them to work on OSX and yours is the first that works and was simple to set up.

I've tried it once and fed it a PGN file and it generated this basically

1. d4 e5 2. d5 { A40 Englund Gambit Complex Declined } 2... Bc5 3. c4 c6 4. Nc3 d6 5. e4 cxd5 6. cxd5 Nf6 7. Bb5+ Bd7 8. Bxd7+ Qxd7 9. Nf3 a6 10. O-O O-O 11. Be3 $6 { -0.62 } ( 11. Nh4 Qd8 12. Nf5 Nbd7 13. Qf3 g6 14. Bh6 Re8 15. Na4 a5 { 0.79/19 } ) 11... Bxe3 12. fxe3 b5 13. Rc1 b4 $6 { 0.71 } ( 13... Qa7 14. Nh4 { -0.63/20 } ) 14. Nb1 $6 { -0.51 } ( 14. Na4 { 0.78/20 } ) 14... Nxe4 15. a3 $6 { -1.49 } ( 15. Nbd2 Nxd2 { -0.08/20 } ) 15... bxa3 16. Nxa3 Ra7 17. Nc4 Rc7 18. Na5 $2 { -2.67 } ( 18. Qc2 f5 19. Nfd2 Nxd2 20. Qxd2 Qe7 21. Qb4 Rc5 22. Qa3 Rfc8 { -0.60/21 } ) 18... Qb5 $4 { 2.66 } ( 18... Rxc1 19. Qxc1 { -2.23/20 } ) 19. Rxc7 Qxa5 20. Qc2 Nc5 $4 { 7.04 } ( 20... Qb6 21. Kh1 { 0.87/20 } ) 21. Rb1 $4 { -5.75 } ( 21. Ng5 e4 { 7.01/22 } ) 21... Qxc7 22. b4 Qb7 $4 { -1.49 } ( 22... Ne6 23. Qc1 Rc8 24. Qxc7 Nxc7 25. Rc1 Nd7 26. Rc6 Kf8 27. Rxd6 { -5.44/23 } ) 23. bxc5 Qxd5 24. cxd6 Qxd6 25. Qe4 $6 { -3.63 } ( 25. h3 h6 { -2.42/19 } ) 25... f6 $6 { -2.09 } ( 25... Nd7 26. h3 Rc8 27. Qg4 Rc7 28. Nh4 Qd3 29. Re1 Qd2 30. Rf1 { -3.55/20 } ) 26. Qc4+ Kh8 27. Kf2 Rd8 $2 { -1.26 } ( 27... Nd7 { -3.42/20 } ) 28. Re1 $2 { -4.19 } ( 28. Rb7 a5 { -1.33/21 } ) 28... Nc6 $2 { -1.82 } ( 28... Nd7 29. Re2 { -4.01/19 } ) 29. Qxa6 Qc5 30. Qe2 $6 { -2.84 } ( 30. Qa4 Ne7 { -1.59/19 } ) 30... Rb8 $6 { -1.45 } ( 30... e4 31. Nd2 Ne5 32. Kg1 Qc2 33. Nf1 Qxe2 34. Rxe2 g6 35. h3 { -2.69/21 } ) 31. Rd1 h6 32. Ne1 $2 { -3.72 } ( 32. Qd3 Rd8 { -1.58/19 } ) 32... Qc3 33. Rd3 Qc5 34. Rd2 $2 { -3.56 } ( 34. Rd7 f5 { -2.00/19 } ) 34... Ne7 $6 { -1.97 } ( 34... e4 35. h3 { -3.18/19 } ) 35. Nd3 Qc7 36. Nb2 Nf5 37. Nc4 Qc5 38. Nb2 $2 { -2.88 } ( 38. Qd3 Ne7 { -1.19/19 } ) 38... Rb3 39. Nd1 Qc3 $4 { 12.09 } ( 39... e4 40. Rc2 { -3.82/19 } ) 40. g4 $4 { 0.38 } ( 40. Nxc3 Rb8 41. Qh5 Nd4 42. exd4 Rd8 43. Ne4 exd4 44. Qg6 f5 { 11.25/23 } ) 40... Qc5 $4 { 3.32 } ( 40... Qc8 { 0.23/19 } ) 41. gxf5 Qb4 $4 { Mate in 7 } ( 41... Rb8 42. Kg2 { 3.30/19 } ) 42. e4 $4 { 2.94 } ( 42. Rd8+ Kh7 43. Qh5 Qh4+ 44. Qxh4 Rd3 45. Rxd3 e4 46. Rd8 g5 47. Qh5 g4 48. Qg6# ) 42... Rb2 $4 { 13.23 } ( 42... Qb5 43. Qxb5 { 3.41/20 } ) 43. Rxb2 1-0

I'm trying to make sense of what I'm seeing here. I intend to consume this data programatically and not just copy/pasting it into a PGN reader

The first part I'm confused about is.. what does do exactly? It seems like it goes through the whole game and makes note of missed opportunities.. on both sides?

Is that right? What if I only want to see missed opportunities from one side's perspective.. such as from white's perspective.. is there an option for that?

Then I note that there are $2, $4 and $6

Are those suppose to represent inaccuracies, blunders.. and something else? If so.. is there a mapping somewhere that corresponds to the different possible symbols that can be used to signify something like that?

Lastly, is it possible to pass it an additional option that would return the score after every single move?

Many thanks for taking the time to educate me, I hope to use your software very soon!

lazydroid commented 3 years ago

https://en.wikipedia.org/wiki/Numeric_Annotation_Glyphs

etc.

vesper8 commented 3 years ago

Excellent thank you! I guess these are the NAGs I saw many references to. Would be helpful to drop that wikipedia link in the Readme IMO.. not everyone is familiar with this terminology

lazydroid commented 3 years ago

This repo is not maintained since 2019 (it says this clearly on README page), so the chances are slim. I'll make a fork and fix a few things here and there, but cannot promise if the author will be willing to put them back into the codebase.

rpdelaney commented 3 years ago

Thanks for jumping in with the explanation. See also #15. However, python-chess has changed a lot since I originally wrote this script, so maybe the behavior has changed there. Edit: Also, #14

rpdelaney commented 3 years ago

The first part I'm confused about is.. what does do exactly? It seems like it goes through the whole game and makes note of missed opportunities.. on both sides?

It compares the engine evaluation of the played move with the engine evaluation of the engine's bestmove. If the played move is sufficiently worse, it adds an annotation with the engine's primary variation. Which NAG is used is determined by how bad the move was.

Is that right? What if I only want to see missed opportunities from one side's perspective.. such as from white's perspective.. is there an option for that?

This script does not have that feature, no. I've leveled up considerably in python since I wrote this (it was actually a project to teach myself python in the first place, so it's the very first serious python application I ever did) and I regard the current state of this code as frankly more effort to maintain than it's worth, let alone extend. Every now and then I kick around the thought of doing a python-chess-annotator-ng from scratch with more of the python skills I've developed since, but other things always get in the way.

rpdelaney commented 3 years ago

Lastly, is it possible to pass it an additional option that would return the score after every single move?

This is also not a feature, although it wouldn't be a tremendous amount of work to extend the script to do that. You would probably want to add a command-line switch to change the value of NEEDS_ANNOTATION_THRESHOLD to 0 (or a user-defined value).

Edit: Bear in mind that a value of 0 would mean you would also get annotations when you played the engine's bestmove, which might not make a lot of sense.