Skip to content

Releases: niklasf/python-chess

python-chess v1.2.0

22 Oct 11:41
v1.2.0
Compare
Choose a tag to compare
New features:

* Added ``chess.Board.ply()``.
* Added ``chess.pgn.GameNode.ply()`` and ``chess.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(*, mate_score: int) -> int`` overload.

Changes:

* The ``PovScore`` returned by ``chess.pgn.GameNode.eval()`` is now always
  relative to the side to move. The ambiguity around ``[%eval #0]`` has been
  resolved to ``Mate(-0)``. This makes sense, given that the authors had
  standard chess in mind (where a game ending move is always a loss for the
  opponent). Previously this would be parsed as ``None``.
* Typed ``chess.engine.InfoDict["wdl"]`` as the new ``chess.engine.PovWdl``,
  rather than ``Tuple[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 of ``chess.Board.fen()`` and
  ``chess.Board.epd()`` is now typed as ``Literal["legal", "fen", "xfen"]``
  rather than ``str``.

python-chess v1.1.0

04 Oct 13:39
v1.1.0
Compare
Choose a tag to compare
New features:

* Added `chess.svg.board(..., orientation)`. This is a more idiomatic way to
  set the board orientation than `flipped`.
* Added `chess.svg.Arrow.pgn()` and `chess.svg.Arrow.from_pgn()`.

Changes:

* Further relaxed `chess.Board.parse_san()`. Now accepts fully specified moves
  like `e2e4`, even if that is not a pawn move, castling notation with zeros,
  null moves in UCI notation, and null moves in XBoard notation.

python-chess v1.0.1

24 Sep 19:48
v1.0.1
d284ecc
Compare
Choose a tag to compare
Bugfixes:

* `chess.svg`: Restore SVG Tiny compatibility by splitting colors like
  `#rrggbbaa` into a solid color and opacity.

python-chess v1.0.0

24 Sep 16:40
v1.0.0
d92c6dd
Compare
Choose a tag to compare
Changes:

* Now requires Python 3.7+.
* `chess.engine` will now cut off illegal principal variations at the first
  illegal move instead of discarding them entirely.
* `chess.engine.EngineProtocol` renamed to `chess.engine.Protocol`.
* `chess.engine.Option` is no longer a named tuple.
* Renamed `chess.gaviota` internals.
* Relaxed type annotations of `chess.pgn.GameNode.variation()` and related
  methods.
* Changed default colors of `chess.svg.Arrow` and
  `chess.pgn.GameNode.arrows()`. These can be overriden with the new
  `chess.svg.board(..., colors)` feature.
* Documentation improvements. Will now show type aliases like `chess.Square`
  instead of `int`.

Bugfixes:

* Fix insufficient material with same-color bishops on both sides.
* Clarify that `chess.Board.can_claim_draw()` and related methods refer to
  claims by the player to move. Three-fold repetition could already be claimed
  before making the final repeating move. `chess.Board.can_claim_fifty_moves()`
  now also allows a claim before the final repeating move. The previous
  behavior is `chess.Board.is_fifty_moves()`.
* Fix parsing of green arrows/circles in `chess.pgn.GameNode.arrows()`.
* Fix overloaded type signature of `chess.engine.Protocol.engine()`.

New features:

* Added `chess.parse_square()`, to be used instead of
  `chess.SQUARE_NAMES.index()`.
* Added `chess.Board.apply_mirror()`.
* Added `chess.svg.board(..., colors)`, to allow overriding the default theme.

python-chess v0.31.4

09 Aug 11:46
v0.31.4
Compare
Choose a tag to compare
Bugfixes:

* Fix inconsistency where `board.is_legal()` was not accepting castling moves
  in Chess960 notation (when board is in standard mode), while all other
  methods did.
* Fix `chess.pgn.GameNode.set_clock()` with negative or floating point values.
* Avoid leading and trailing spaces in PGN comments when setting annotations.

New features:

* Finish typing and declare support for mypy.

python-chess v0.31.3

18 Jul 09:56
v0.31.3
Compare
Choose a tag to compare
Bugfixes:

* Custom castling rights assigned to `board.castling_rights` or castling rights
  left over after `Board.set_board_fen()` were not correctly cleaned after
  the first move.

Changes:

* Ignore up to one consecutive empty line between PGN headers.
* Added PGN Variant `From Position` as an alias for standard chess.
* `chess.pgn.FileExporter.result()` now returns the number of written
  characters.
* `chess.engine` now avoids sending 0 for search limits, which some engines
  misunderstand as no limit.
* `chess.engine` better handles null moves sent to the engine.
* `chess.engine` now gracefully handles `NULL` ponder moves and uppercase
  moves received from UCI engines, which is technically invalid.

New features:

* Added `chess.pgn.GameNode.{clock, set_clock}()` to read and write
  `[%clk ...]` **PGN annotations**.
* Added `chess.pgn.GameNode.{arrows, set_arrows}()` to read and write
  `[%csl ...]` and `[%cal ...]` PGN annotations.
* Added `chess.pgn.GameNode.{eval, set_eval}()` to read and write
  `[%eval ...]` PGN annotations.
* Added `SquareSet.ray(a, b)` and `SquareSet.between(a, b)`.

python-chess v0.31.2

02 Jun 16:20
v0.31.2
Compare
Choose a tag to compare
Bugfixes:

* Fix rejected/accepted in `chess.engine.XBoardProtocol`.
* Misc typing fixes.

Changes:

* Deprecated `chess.syzygy.is_table_name()`. Replaced with
  `chess.syzygy.is_tablename()` which has additional parameters and defaults to
  `one_king`.
* Take advantage of `int.bit_count()` coming in Python 3.10.

python-chess v0.31.1

05 May 15:46
v0.31.1
Compare
Choose a tag to compare
Bugfixes:

* `RacingKingsBoard.is_variant_win()` no longer incorrectly returns `True`
  for drawn positions.
* Multiple moves for EPD opcodes *am* and *bm* are now sorted as required by
  the specification.
* Coordinates of SVG boards are now properly aligned, even when rendered as
  SVG Tiny.

Changes:

* SVG boards now have a background color for the coordinate margin, making
  coordinates readable on dark backgrounds.
* Added *[Variant "Illegal"]* as an alias for standard chess
  (used by Chessbase).

Features:

* Added `Board.find_move()`, useful for finding moves that match human input.

python-chess v0.31.0

21 Apr 19:17
v0.31.0
Compare
Choose a tag to compare
Changes:

* Replaced lookup table `chess.BB_BETWEEN[a][b]` with a function
  `chess.between(a, b)`. Improves initialization and runtime performance.
* `chess.pgn.BaseVisitor.result()` is now an abstract method, forcing
  subclasses to implement it.
* Removed helper attributes from `chess.engine.InfoDict`. Instead it is now
  a `TypedDict`.
* `chess.engine.PovScore` equality is now semantic instead of structural:
  Scores compare equal to the negative score from the opposite point of view.

Bugfixes:

* `chess.Board.is_irreversible()` now considers ceding legal en-passant
  captures as irreversible. Also documented that false-negatives due to forced
  lines are by design.
* Fixed stack overflow in `chess.pgn` when exporting, visiting or getting the
   final board of a very long game.
* Clarified documentation regarding board validity.
* `chess.pgn.GameNode.__repr__()` no longer errors if the root node has invalid
  FEN or Variant headers.
* Carriage returns are no longer allowed in PGN header values, fixing
  reparsability.
* Fixed type error when XBoard name or egt features have a value that looks
  like an integer.
* `chess.engine` is now passing type checks with mypy.
* `chess.gaviota` is now passing type checks with mypy.

Features:

* Added `chess.Board.gives_check()`.
* `chess.engine.AnalysisResult.wait()` now returns `chess.engine.BestMove`.
* Added `empty_square` parameter for `chess.Board.unicode()` with better
  aligned default (⭘).

python-chess v0.30.1

18 Jan 13:47
v0.30.1
Compare
Choose a tag to compare
Changes:

* Positions with more than two checkers are considered invalid and
  `board.status()` returns `chess.STATUS_TOO_MANY_CHECKERS`.
* Pawns drops in Crazyhouse are considered zeroing and reset
  `board.halfmove_clock` when played.
* Now validating file sizes when opening Syzygy tables and Polyglot opening
  books.
* Explicitly warn about untrusted tablebase files and chess engines.

Bugfixes:

* Fix Racing Kings game end detection: Black cannot catch up if their own
  pieces block the goal. White would win on the turn, so this did not
  impact the game theoretical outcome of the game.
* Fix bugs discovered by fuzzing the EPD parser: Fixed serialization of
  empty strings, reparsability of empty move lists, handling of non-finite
  floats, and handling of whitespace in opcodes.

Features:

* Added `board.checkers()`, returning a set of squares with the pieces giving
  check.