Bugfixes:
- Fixed unintended collisions and optimized
chess.Piece.__hash__()
. - Fixed false-positive
chess.STATUS_IMPOSSIBLE_CHECK
if checkers are aligned with other king.
Changes:
- Also detect
chess.STATUS_IMPOSSIBLE_CHECK
if checker is aligned with en passant square and king.
New features:
- Implemented Lichess winning chance model for
chess.engine.Score
:score.wdl(model="lichess")
.
Bugfixes:
- Added a new reason for
board.status()
to be invalid:chess.STATUS_IMPOSSIBLE_CHECK
. This detects positions where two sliding pieces are giving check while also being aligned with the king on the same rank, file, or diagonal. Such positions are impossible to reach, break Stockfish, and maybe other engines.
Bugfixes:
chess.pgn.read_game()
now properly detects variant games with Chess960 castling rights (as well as mislabeled Standard Chess960 games). Previously, all castling moves in such games were rejected.
Changes:
Introduced
chess.pgn.ChildNode
, a subclass ofchess.pgn.GameNode
for all nodes other than the root node, and convertedchess.pgn.GameNode
to an abstract base class. This improves ergonomics in typed code.The change is backwards compatible if using only documented features. However, a notable undocumented feature is the ability to create dangling nodes. This is no longer possible. If you have been using this for subclassing, override
GameNode.add_variation()
instead ofGameNode.dangling_node()
. It is now the only method that creates child nodes.
Bugfixes:
- Removed broken
weakref
-based caching inchess.pgn.GameNode.board()
.
New features:
- Added
chess.pgn.GameNode.next()
.
Bugfixes:
- Fixed regression where releases were uploaded without the
py.typed
marker.
Changes:
The primary location for the published package is now https://pypi.org/project/chess/. Thanks to Kristian Glass for transferring the namespace.
The old https://pypi.org/project/python-chess/ will remain an alias that installs the package from the new location as a dependency (as recommended by PEP423).
ModuleNotFoundError: No module named 'chess'
after upgrading from previous versions? Runpip install --force-reinstall chess
(due to niklasf#680).
New features:
- Added
chess.Board.ply()
. - Added
chess.pgn.GameNode.ply()
andchess.pgn.GameNode.turn()
. - Added
chess.engine.PovWdl
,chess.engine.Wdl
, and conversions from scores:chess.engine.PovScore.wdl()
,chess.engine.Score.wdl()
. - Added
chess.engine.Score.score(*, mate_score: int) -> int
overload.
Changes:
- The
PovScore
returned bychess.pgn.GameNode.eval()
is now always relative to the side to move. The ambiguity around[%eval #0]
has been resolved toMate(-0)
. This makes sense, given that the authors of the specification probably had standard chess in mind (where a game-ending move is always a loss for the opponent). Previously, this would be parsed asNone
. - Typed
chess.engine.InfoDict["wdl"]
as the newchess.engine.PovWdl
, rather thanTuple[int, int, int]
. The new type is backwards compatible, but it is recommended to use its documented fields and methods instead. - Removed
chess.engine.PovScore.__str__()
. String representation falls back to__repr__
. - The
en_passant
parameter ofchess.Board.fen()
andchess.Board.epd()
is now typed asLiteral["legal", "fen", "xfen"]
rather thanstr
.
New features:
- Added
chess.svg.board(..., orientation)
. This is a more idiomatic way to set the board orientation thanflipped
. - Added
chess.svg.Arrow.pgn()
andchess.svg.Arrow.from_pgn()
.
Changes:
- Further relaxed
chess.Board.parse_san()
. Now accepts fully specified moves likee2e4
, even if that is not a pawn move, castling notation with zeros, null moves in UCI notation, and null moves in XBoard notation.
Bugfixes:
chess.svg
: Restored SVG Tiny compatibility by splitting colors like#rrggbbaa
into a solid color and opacity.
See CHANGELOG-OLD.rst
for changes up to v1.0.0.