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

Extract Moves as Strings from PGN file Using python-chess

I am using the module python-chess (https://python-chess.readthedocs.io/en/latest/index.html) to extract analyze 4 million chess games (http://caissabase.co.uk/). How do I load all moves for a game as strings into a list? The idea is for me to be…
1
vote
1 answer

Why are there different scores when chess.engine analyses a position multiple times in the same script?

beginner programmer here, trying to make an app that detects blunders and wanting to learn more about the chess.engine library. I assume that using the analyse function is a discrete, self-contained process that doesn't rely on cache or memory of…
Vigoxin
  • 63
  • 7
1
vote
1 answer

How to track movement of a single chess piece?

I'm using python-chess and I would like to know what is a good way to track movement of let say a black King throughout a single match recorded in pgn format using python-chess. Essentially creating a string of every position it achieved.
1
vote
1 answer

How to guess the positions of the queens in a chess game

I recently participated in a programming competition and I was able to answer six out of seven questions in time. the last question was: "take a number from the user and make a chess board by the power of the given number and put as many queens as…
Omid Ketabollahi
  • 154
  • 2
  • 13
1
vote
2 answers

AttributeError: 'NoneType' object has no attribute 'symbol' python-chess

I'm working on rating positions but I don't know if a piece is on a certain square. when I run my code I get AttributeError: 'NoneType' object has no attribute 'symbol' Here is the code: for i in range(0,8): for j in range(0,8): …
Kevin
  • 13
  • 4
1
vote
0 answers

How to create a Lichess-like engine-to-player communication API in Python, Python-chess and Flask for my own chess based website?

So, this is for a big college project that I am trying to create a website with the player being able to login, play with an engine (which would run locally on a team mate's PC or a server) then display the output, let the player play moves and…
1
vote
1 answer

Printing remaining clock time per move with the python-chess library

I want to sequentially print the remaining clock time (one string per move at a time) from a game I read (using the python-chess library) from a text file. So, say I have a pgn file with a game that has the following moves... f3 { [%clk 0:05:00] }…
BaDer
  • 53
  • 1
  • 3
1
vote
2 answers

Python Chess: How to stop chess.engine.SimpleEngine.popen_uci() from opening the shell

I'm making my own chess GUI and am using python chess and stockfish for it. After freezing it into an executable, every time I call chess.engine.SimpleEngine.popen_uci('location\\of\\stockfish'), it opens the shell for stockfish and if I close the…
IgnisNoctum
  • 41
  • 1
  • 8
1
vote
1 answer

Python-Chess Import Failed

I am trying to Install python-chess on Ubuntu 16. Installed it via pip3, but getting error while importing chess. ujesh@suyodhana:~$ pip3 install python-chess Collecting python-chess Using cached…
Ujesh Lal
  • 111
  • 1
  • 5
1
vote
0 answers

Integrating chess-svg texture into kivy object

Previously I have had success in integrating bytes of png files into a kivy image using the obj.texture reference. I am currently trying to do this with a chess.svg string but am not having much success. MWE below: # dependencies import kivy from…
Justapigeon
  • 560
  • 1
  • 8
  • 22
1
vote
0 answers

python-chess returns "none" when the score is like "-M8"

I'm using python 3.6 with Jupyter and Anaconda. The script goes move by move in a chess game from a PGN file, and it returns a score. That works great. The problem comes when the score returned is "-M8", which means black can give checkmate in 8…
JonTargaryen
  • 1,317
  • 3
  • 11
  • 18
1
vote
1 answer

How to get a string of the FEN position

After I do import chess board = chess.Board() how can I have a string with the FEN of the position? In other words, how can I extract from board the FEN of the position as a string, with the same output as if I…
3sm1r
  • 520
  • 4
  • 19
1
vote
2 answers

Why only call a private function in a public function?

I was wandering in the source code of the fabulous python-chess library when I saw the following code: def _reset_board(self): # code... def reset_board(self): self._reset_board() The reset_board() function only does one thing, call its…
Null User
  • 338
  • 1
  • 4
  • 17
1
vote
3 answers

Get clicked chess piece from an SVG chessboard

I am developing a chess GUI in Python 3.6.3 using PyQt5 5.9.1 (GUI framework) and python-chess 0.21.1 (chess library) on Windows 10. I want to get the value of a piece that was clicked on an SVG chessboard (provided by python-chess) so that I can…
Boštjan Mejak
  • 827
  • 9
  • 23
1
vote
0 answers

Slicing and List Copies

I'm in the very early stages of my chess implementation and I'm working on how to move the pawn. The problem is, I can't figure out what is going on with the list slicing! This is my variable board: board = [['R', 'N', 'B', 'Q', 'K', 'B', 'N',…
user6142489
  • 512
  • 2
  • 10
  • 28
1 2 3
8 9