niklasf on master
Update cp multiplier to match L… Merge pull request #954 from ja… (compare)
popen_uci(..., startupinfo=..., creationflags=...)
are passed along to subprocess.Popen
transform()
, except that it modifies the existing board instead of creating a new one
@niklasf, please fix the alignment of white and black pawns, because their offset from the center of a square on the x axis is exactly 0.5 pixels to the left.
I have fixed this by editing the translate() data of an already generated SVG and added 0.5 pixels to the x attribute.
<use href="#white-pawn" transform="translate(15, 285)"/>
was fixed to
<use href="#white-pawn" transform="translate(15.5, 285)"/>
@niklasf, there's a bug in chess.svg, namely on line 71 (CHECK_GRADIENT). The "r" attribute is missing there, so PyQt6 doesn't render the radial gradient at all and produces an error. PyQt5, for some reason, works without the "r" attribute. And as tested, adding the "r" attribute works in both frameworks. Adding the "r" attribute doesn't brake anyone's code, so it's safe to add it.
Please fix line 71 in chess.svg to be:
CHECK_GRADIENT = """<radialGradient id="check_gradient" r="0.5"><stop offset="0%" stop-color="#ff0000" stop-opacity="1.0" /><stop offset="50%" stop-color="#e70000" stop-opacity="1.0" /><stop offset="100%" stop-color="#9e0000" stop-opacity="0.0" /></radialGradient>""" # noqa: E501
How to get the best-understandable score of a chessboard position (i.e., a centipawn score in the format like 0.41
) returned by result.info["score"].white().score()
(which returns a not-so-understandable value in the format like 41.00
)?
Well, my approach is that I just divide the returned value of that score()
method by 100
. So like this: result.info["score"].white().score() / 100
(I prefer to have centipawn scores from White's point of view).
There's no mention of this "formula" (dividing by 100
) in the python-chess documentation. There could (maybe even should) be a method (named perhaps centipawn_score()
) that divides the returned value of that score()
method by 100
. It'd be used as result.info["score"].white().centipawn_score()
to get the actual (centipawn) score (like 0.41
, as it is displayed by all chess GUIs I know) and not a (perhaps strange) number (like 41.00
).
Can this be implemented?
find_move()
method of chess.Board()
to return None
if no legal move is found by it. It now raises a ValueError
exception, but I think that could be improved. It's better to do if board.find_move(some_move) is not None
than to have a try/except
block.
my_default_theme = {
"coord": "#f0f6fd80",
"margin": "#15781b80",
"arrow red": "#88202080",
"arrow blue": "#00308880",
"arrow green": "#15781b80",
"square dark": "#e5e5e5ff",
"square light": "#f0f6fdff",
"arrow yellow": "#e68f0080",
"square dark lastmove": "#8b000080",
"square light lastmove": "#8b000080",
}
my_default_theme
dictionary to chess.svg.board(..., colors=my_default_theme)
@SamQ26867433_twitter, you need to have the chessboard quadraticly shaped, otherwise you end up with squares that are not squares anymore but rectangles, and this messes up the coordinate system of your chessboard; clicking on the a1 square, for example, is registered as being the a2 square, etc.
I propose you have options for displaying a small chessboard, a medium chessboard and a big chessboard, each of its size being quadraticly shaped; say, 400×400 chessboard size for the small version, 500×500 for the medium version and 600×600 for the big version... you then have complete control over the coordinate system of your chessboard, because your coordinate formula takes the size of the chessboard (whichever of those 3 sizes is chosen by the user of your application), and then every square is registered correctly, because the formula adapts to whichever size you pass into it, but it must be quadratic (400×400, 500×500, etc.)
you can't freely stretch and shrink the chessboard, that's a limitation of the chessboard (and its squares of which it is comprised) being naturally quadratic...