niklasf on master
Link python-chess-engine-extens… (compare)
niklasf on master
Move required Python to install… (compare)
@niklasf python-chess is really great! When first using chess.polyglot, all went well where I got:
import chess
import chess.polyglot
board = chess.Board()
with chess.polyglot.open_reader(polyglot_books/Cerebellum3Merge.bin') as reader:
for entry in reader.find_all(board):
print(entry.move, entry.weight, entry.learn)
e2e4 255 0
d2d4 127 0
So how do I get the rest of possible openings in book? (e.g. - 1.c4, 1.Nf3....etc)
@niklasf, don't you think some aliases are missing in chess.variant
for the 3-check chess variant? Currently, python-chess has these aliases for it: aliases = ["Three-check", "Three check", "Threecheck", "Three check chess", "3-check", "3 check", "3check"]
The list should be:aliases = ["Three-check", "Three check", "Threecheck", "Three-check chess", "Three check chess", "Threecheck chess", "3-check", "3 check", "3check", "3-check chess", "3 check chess", "3check chess"]
@niklasf, I have found a bug in python-chess. The bug involves chess.Board().status()
. Here's my proof of concept:
>>> import chess
>>> chess.Board("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR b KQkq - 0 1").status()
<Status.VALID: 0>
As you can see, I passed the starting FEN to chess.Board()
, but I set Black (b
) as being the first to move. And since this is clearly not valid, please add a check to the status()
method to detect whether it is actually White that is on turn to move in the starting position.
Fixing this bug also involves adding a new Status
enum.
w
is a b
(color part of the FEN) in the starting position, indicating that Black starts a game of chess. And since White always moves first, not Black, so a FEN like this should be reported as not valid by the status()
method.
1
: https://github.com/niklasf/python-chess/blob/eef8a29907e91662a24a4f0a79416f14c8a6d24c/chess/svg.py#L51
hi @9acca9. did you find https://python-chess.readthedocs.io/en/latest/pgn.html#writing ?
oh, thanks! i will try it! Thanks
board
. see the example in https://python-chess.readthedocs.io/en/latest/pgn.html#chess.pgn.read_game for how to do that. then just use board.fen()