niklasf / python-chess

A chess library for Python, with move generation and validation, PGN parsing and writing, Polyglot opening book reading, Gaviota tablebase probing, Syzygy tablebase probing, and UCI/XBoard engine communication
https://python-chess.readthedocs.io/en/latest/
GNU General Public License v3.0
2.4k stars 526 forks source link

feat: Adds support for displaying NAGs in the chess.svg.board AND other optimizations chess.svg.board function #1062

Open Vikasg7 opened 8 months ago

Vikasg7 commented 8 months ago
niklasf commented 7 months ago

Nice addition, thanks!

Maybe a nags: Iterable[int] parameter would be more future-proof? We can currently only display one, but it could at least pick the most relevant one and show it. It would also be easier to just pass node.nags then, without having to filter out all the irrelevant ones (e.g., Ke2 $70 $6 $77).

Vikasg7 commented 7 months ago

Hi, I just covered 5 out of 6 here (6th being the speculative which I couldn't find the SVG for). Also, I am not sure how we are gonna decide the relevant ones in case of multiple nags. Also, I forgot to mention that we are covering only 5 in the function docs.

So if we decide on displaying multiple nags, it would be difficult to decide where to show them in the square as I am already moving the nag left or right based on where the arrow is coming from so that it doesn't overlap the arrow.

Glyphs show up at the end of the attached video which I am trying to produce with python.

https://github.com/niklasf/python-chess/assets/14152817/dcbb545e-2b71-4439-99d1-37d345437e33