Releases: niklasf/python-chess
python-chess v0.12.0
* Python 2.6 support. Patch by vdbergh. * Pure Python Gaviota tablebase probing. Thanks to Jean-Noël Avila.
python-chess v0.11.1
Bugfixes: * `syzygy.Tablebases.probe_dtz()` has was giving wrong results for some positions with possible en passant capturing. This was found and fixed upstream: https://github.com/official-stockfish/Stockfish/issues/394. * Ignore extra spaces in UCI `info` lines, as for example sent by the Hakkapeliitta engine. Thanks to Jürgen Précour for reporting
python-chess v0.11.0
Changes: * **Chess960** support and the **representation of castling moves** has been changed. The constructor of board has a new `chess960` argument, defaulting to `False`: `Board(fen=STARTING_FEN, chess960=False)`. That property is available as `Board.chess960`. In Chess960 mode the behaviour is as in the previous release. Castling moves are represented as a king move to the corresponding rook square. In the default standard chess mode castling moves are represented with the standard UCI notation, e.g. `e1g1` for king-side castling. `Board.uci(move, chess960=None)` creates UCI representations for moves. Unlike `Move.uci()` it can convert them in the context of the current position. `Board.has_chess960_castling_rights()` has been added to test for castling rights that are impossible in standard chess. The modules `chess.polyglot`, `chess.pgn` and `chess.uci` will transparently handle both modes. * In a previous release `Board.fen()` has been changed to only display an en passant square if a legal en passant move is indeed possible. This has now also been adapted for `Board.shredder_fen()` and `Board.epd()`. New features: * Get individual FEN components: `Board.board_fen()`, `Board.castling_xfen()`, `Board.castling_shredder_fen()`. * Use `Board.has_legal_en_passant()` to test if a position has a legal en passant move. * Make `repr(board.legal_moves)` human readable.
python-chess v0.10.1
Bugfixes: * Fix use-after-free in Gaviota tablebase initialization.
python-chess v0.10.0
New dependencies:
- If you are using Python < 3.2 you have to install
futures
in order to
use thechess.uci
module.
Changes:
-
There are big changes in the UCI module. Most notably in async mode multiple
commands can be executed at the same time (e.g.go infinite
and then
stop
orgo ponder
and thenponderhit
).go infinite
andgo ponder
will now wait for a result, i.e. you may have
to callstop
orponderhit
from a different thread or run the commands
asynchronously.stop
andponderhit
no longer have a result. -
The values of the color constants
chess.WHITE
andchess.BLACK
have been
changed. PreviouslyWHITE
was0
,BLACK
was1
. NowWHITE
isTrue
,
BLACK
isFalse
. The recommended way to invertcolor
is using
not color
. -
The pseudo piece type
chess.NONE
has been removed in favor of just using
None
. -
Changed the
Board(fen)
constructor. If the optionalfen
argument is not
given behavior did not change. However ifNone
is passed explicitly an
empty board is created. Previously the starting position would have been
set up. -
Board.fen()
will now only show completely legal en-passant squares. -
Board.set_piece_at()
andBoard.remove_piece_at()
will now clear the
move stack, because the old moves may not be valid in the changed position. -
Board.parse_uci()
andBoard.push_uci()
will now accept null moves. -
Changed shebangs from
#!/usr/bin/python
to#!/usr/bin/env python
for
better virtualenv support. -
Removed unused game data files from repository.
Bugfixes:
- PGN: Prefer the game result from the game termination marker over
*
in the
header. These should be identical in standard compliant PGNs. Thanks to
Skyler Dawson for reporting this. - Polyglot:
minimum_weight
forfind()
,find_all()
andchoice()
was
not respected. - Polyglot: Negative indexing of opening books was raising
IndexError
. - Various documentation fixes and improvements.
New features:
-
Experimental probing of Gaviota tablebases via libgtb.
-
New methods to construct boards:
>>> chess.Board.empty() Board('8/8/8/8/8/8/8/8 w - - 0 1')
>>> board, ops = chess.Board.from_epd("4k3/8/8/8/8/8/8/4K3 b - - fmvn 17; hmvc 13") >>> board Board('4k3/8/8/8/8/8/8/4K3 b - - 13 17') >>> ops {'fmvn': 17, 'hmvc': 13}
-
Added
Board.copy()
and hooks to let the copy module to the right thing. -
Added
Board.has_castling_rights(color)
,
Board.has_kingside_castling_rights(color)
and
Board.has_queenside_castling_rights(color)
. -
Added
Board.clear_stack()
. -
Support common set operations on
chess.SquareSet()
.
python-chess v0.9.1
Bugfixes:
- UCI module could not handle castling ponder moves. Thanks to Marco Belli for
reporting. - The initial move number in PGNs was missing, if black was to move in the
starting position. Thanks to Jürgen Précour for reporting. - Detect more impossible en-passant squares in
Board.status()
. There already
was a requirement for a pawn on the fifth rank. Now the sixth and seventh
rank must be empty, additionally. We do not do further retrograde analisys,
because these are the only cases affecting move generation.
python-chess v0.8.3
Bugfixes:
- The initial move number in PGNs was missing, if black was to move in the
starting position. Thanks to Jürgen Précour for reporting. - Detect more impossible en-passant squares in
Board.status()
. There already
was a requirement for a pawn on the fifth rank. Now the sixth and seventh
rank must be empty, additionally. We do not do further retrograde analysis,
because these are the only cases affecting move generation.
python-chess v0.9.0
This is a big update with quite a few breaking changes. Carefully review
the changes before upgrading. It's no problem if you can not update right now.
The 0.8.x branch still gets bugfixes.
Incompatible changes:
-
Removed castling right constants. Castling rights are now represented as a
bitmask of the rook square. For example:.. code:: python
>>> board = chess.Board() >>> # Standard castling rights. >>> board.castling_rights == chess.BB_A1 | chess.BB_H1 | chess.BB_A8 | chess.BB_H8 True >>> # Check for the presence of a specific castling right. >>> can_white_castle_queenside = chess.BB_A1 & board.castling_rights
Castling moves were previously encoded as the corresponding king movement in
UCI, e.g.e1f1
for white kingside castling. Now castling moves are
encoded as a move to the corresponding rook square (UCI_Chess960
-style),
e.g.e1a1
.You may use the new methods
Board.uci(move, chess960=True)
,
Board.parse_uci(uci)
andBoard.push_uci(uci)
to handle this
transparently.The
uci
module takes care of converting moves when communicating with an
engine that is not inUCI_Chess960
mode. -
The
get_entries_for_position(board)
method of polyglot opening book readers
has been changed tofind_all(board, minimum_weight=1)
. By default entries
with weight 0 are excluded. -
The
Board.pieces
lookup list has been removed. -
In 0.8.1 the spelling of repetition (was repitition) was fixed.
can_claim_threefold_repetition()
andis_fivefold_repetition()
are the
affected method names. Aliases are now removed. -
Board.set_epd()
will now interpretbm
,am
as a list of moves for the
current position andpv
as a variation (represented by a list of moves).
Thanks to Jordan Bray for reporting this. -
Removed
uci.InfoHandler.pre_bestmove()
and
uci.InfoHandler.post_bestmove()
. -
uci.InfoHandler().info["score"]
is now relative to multipv. Use.. code:: python
>>> with info_handler as info: ... if 1 in info["score"]: ... cp = info["score"][1].cp
where you were previously using
.. code:: python
>>> with info_handler as info: ... if "score" in info: ... cp = info["score"].cp
-
Clear
uci.InfoHandler()
dictionary at the start of new searches
(newon_go()
), not at the end of searches. -
Renamed
PseudoLegalMoveGenerator.bitboard
andLegalMoveGenerator.bitboard
toPseudoLegalMoveGenerator.board
andLegalMoveGenerator.board
,
respectively. -
Scripts removed.
-
Python 3.2 compability dropped. Use Python 3.3 or higher. Python 2.7 support
is not affected.
New features:
- Introduced Chess960 support.
Board(fen)
andBoard.set_fen(fen)
now
support X-FENs. AddedBoard.shredder_fen()
.
Board.status(allow_chess960=True)
has an optional argument allowing to
insist on standard chess castling rules.
AddedBoard.is_valid(allow_chess960=True)
. - Improved move generation using
Shatranj-style direct lookup <http://arxiv.org/pdf/0704.3773.pdf>
_. Removed rotated bitboards. Perft
speed has been more than doubled. - Added
choice(board)
andweighted_choice(board)
for polyglot opening book
readers. - Added
Board.attacks(square)
to determine attacks from a given square.
There already wasBoard.attackers(color, square)
returning attacks to
a square. - Added
Board.is_en_passant(move)
,Board.is_capture(move)
and
Board.is_castling(move)
. - Added
Board.pin(color, square)
andBoard.is_pinned(color, square)
. - There is a new method
Board.pieces(piece_type, color)
to get a set of
squares with the specified pieces. - Do expensive Syzygy table initialization on demand.
- Allow promotions like
e8Q
(usuallye8=Q
) inBoard.parse_san()
and
PGN files. - Patch by Richard C. Gerkin: Added
Board.__unicode__()
just like
Board.__str__()
but with unicode pieces. - Patch by Richard C. Gerkin: Added
Board.__html__()
.
python-chess v0.8.2
Bugfixes:
pgn.Game.setup()
with the standard starting position was failing when the
standard starting position was already set. Thanks to Jordan Bray for
reporting this.
Optimizations:
- Remove
bswap()
from Syzygy decompression hot path. Directly read integers
with the correct endianness.
python-chess v0.8.1
Improvements in this bugfix release:
- Fixed pondering mode in uci module. For example
ponderhit()
was blocking
indefinitely. Thanks to Valeriy Huz for reporting this. - Patch by Richard C. Gerkin: Moved searchmoves to the end of the UCI go
command, where it will not cause other command parameters to be ignored. - Added missing check or checkmate suffix to castling SANs, e.g.
O-O-O#
. - Fixed off-by-one error in polyglot opening book binary search. This would
not have caused problems for real opening books. - Fixed Python 3 support for reverse polyglot opening book iteration.
- Bestmoves may be literally
(none)
in UCI protocol, for example in
checkmate positions. Fix parser and returnNone
as the bestmove in this
case. - Fixed spelling of repetition (was repitition).
can_claim_threefold_repetition()
andis_fivefold_repetition()
are the
affected method names. Aliases are there for now, but will be removed in the
next release. Thanks to Jimmy Patrick for reporting this. - Added
SquareSet.__reversed__()
. - Use containerized tests on Travis CI, test against Stockfish 6, improved
test coverage amd various minor clean-ups.