Questions tagged [python-chess]

For questions about the python-chess library (for questions about your own chess algorithm, use the [chess] tag instead).

Refers to the python-chess library, developed by Niklas Fiekas.

python-chess is a pure Python chess library with move generation, move validation and support for common formats.

This tag should be used only for questions about the python-chess library.

For general questions about chess-playing algorithms, use the tag combined with the tag. If your question is not actually about chess or the algorithms involved, you should not use the tag.

External Links

129 questions
1
vote
1 answer

Creating more than one row in a CSV file/Chess database creation

I am trying to create a database to train a basic machine learning algorithm off of. However, when I run the code, it only creates two rows, but I am trying to create multiple rows, of each individual position in the game, accompanied by a stockfish…
Thayer
  • 35
  • 3
1
vote
1 answer

Python-chess: module 'chess.engine' has no attribute 'SimpleEngine'

This is part of a larger project, but I created a new file to solve this one problem. Sorry, I am still new to coding. Currently, I am trying to get stockfish evaluations for positions in Chess, however whenever I try to run the code, I get…
Thayer
  • 35
  • 3
1
vote
3 answers

How can I manipulate this chess notation with python?

I'm trying to use some chess related libraries in python (e.g. chessnut and chess) and they use the following notation r1bqkb1r/pppp1Qpp/2n2n2/4p3/2B1P3/8/PPPP1PPP/RNB1K1NR b KQkq - 0 4 I've searched about it and didn't find anything. How can I…
1
vote
1 answer

How do I get python-chess SVG rendering working in Google Colab?

I'm trying to get this code sample from python-chess SVG rendering working. import chess import chess.svg chess.svg.piece(chess.Piece.from_symbol("R")) When I run the code, I get the following HTML output, but not the image of a white rook.
Hal Heinrich
  • 544
  • 1
  • 4
  • 21
1
vote
3 answers

convert pgn database to pandas dataframe

Helo! Using chess.pgn to convert a Chess database into a dataframe, to read the nth game from the database do I need to read all the previous ones first? I can't jump directly to the game n? If I want to distribute the processing in a database with…
Hick Nax
  • 43
  • 1
  • 5
1
vote
1 answer

What is game state Moves evaluation in chess? why is stockfish API with python giving me rubbish evaluations

I am analyzing a chess game PGN File. I used the stockfish 13 API to perform game moves Analysis but, the engine is computing some rubbish evaluation scores. the same game gets an evaluation close to 0 for e2e4. but the output of my python code…
skwolvie
  • 139
  • 12
1
vote
1 answer

python chess module doesn't work properly on google colab

I am using the python chess module in a google colab notebook. Specifically, I am running three commands related to this…
BLEB
  • 53
  • 6
1
vote
1 answer

add variations/nodes to games in python-chess

I'm trying to build a chess engine by using the "python-chess"-package My problem is that I want to add variations to games, so I used the method: add_variation(move: chess.Move, *, comment: str = '', starting_comment: str = '', nags: Iterable[int]…
1
vote
1 answer

Python-Chess board.is_checkmate, .is_stalemate, .is_en_passant, .is_check Always Returning True

Just downloaded the Python-Chess module and wanted to test it out; whenever I check the board state by using board.is_checkmate, board.is_stalemate, board.is_check, board.is_en_passant and a print statement, it always returns true. I'm using VSCode…
Ariel
  • 37
  • 1
  • 5
1
vote
1 answer

How to extract black and white moves separately from a Portable Game Notation (PGN) file?

I would like to extract the white moves and black moves made in a chess game seperately, by analyzing the PGN (Portable Game Notation) file, using Python. Example: 1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O b5 6. Bb3 Bb7 7. d3 Be7 8. Nc3 O-O 9.…
Kapil Gund
  • 19
  • 2
1
vote
1 answer

Get Location of Piece in Python-Chess

I am currently building a chess game using Python-Chess, and I am trying to use the SVG module to generate SVG images of the board. One of the parameters for generating an svg is check (here), which is a "square to be marked indicating a check".…
Krishnan Shankar
  • 780
  • 9
  • 29
1
vote
1 answer

Why are logical shifts used when representing a chess board for a Deep Learning task?

Recently I came across a twitch streamer who was working on his own Deep Learning based chess engine. I was going through the code I saw in the video and one thing I didn't quite understand was why he used logical shifts when he was preparing the…
1
vote
1 answer

in python-chess library: "white_clock, white_inc black_clock, black_inc" is internally managed by library? or i need to update it myself?

I'm working with python-chess library, i need to know in python-chess library: "white_clock, white_inc black_clock, black_inc" is internally managed by library? or i need to update it myself? i have a code like this: limit =…
Abdul.Moqueet
  • 902
  • 12
  • 19
1
vote
1 answer

How do i get the played move by comparing two different fens?

So I have two fens. One gotten before the move and one after. How can I get the played move by comparing these 2 fens to each other and returning the answer in uci or any other format. I am using the python-chess library so maybe there is a way to…
Fancy129
  • 49
  • 3
1
vote
2 answers

How to promote a pawn?

I put a FEN where on the next move White can promote a pawn by moving b7a8. In the library that I currently use (and that I want to replace). When doing this type of action, it returns a type of error so you ask why and then you get the indication…
9acca9
  • 19
  • 5
1 2
3
8 9