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
votes
1 answer

How to make a Regular expression to remove all timestamp data from Chess Pgn?

I have a string with the Pgn from a chess.com match. I need to remove all of the time data from the Pgn. Using Regular Expressions how would I accomplish this? '1. e4 {[%clk 0:29:59.9]} 1... e5 {[%clk 0:29:59.1]} 2. Nf3 {[%clk 0:29:58]} 2... Nf6…
-1
votes
1 answer

Tkinter button not displaying image despite existing reference

In a GUI based chess game that I have created using tkinter in Python I'm using images to display the chess piece on the grid button. The image .png files are located within a folder in the same directory as the program. When I run the code the…
Manusman
  • 57
  • 6
-1
votes
1 answer

Mouse click not precise

My application is written using the latest versions of Python 3.7, PyQt5 and python-chess. I have an SVG chessboard, produced by python-chess itself. My application handles mouse clicks on the chessboard which highlight the clicked square. I have a…
Boštjan Mejak
  • 827
  • 9
  • 23
-2
votes
1 answer

Python chess: Check for passed pawns

In a chess position, I wish to check whether any passed pawn exists for white. Is it possible to do so using the python-chess library? If not, how can I implement it? def checkForPassedPawn(position: chess.Board, side_to_move: chess.Color): #…
Boo Who
  • 17
  • 6
-2
votes
1 answer

How do I create graphs like this in python?

enter image description here I would like to generate graphs in this format, does anyone have code to be able to generate
Masmok
  • 1
-2
votes
1 answer

Can't find error in chess code. When piece is moved back it doesn't update the position

I'm making chess in python. It was all working and I had the moves as a list of indexes but I decided to use a class instead as I thought this would be better. However, now the function to get all the legal moves doesn't seem to work and I've found…
-2
votes
1 answer

How to isolate a single game from a pgn file containing multiple games in python?

I have a pgn file with multiple games. I want to separate all the games into different files or just one text file so that I can separate all the White moves and Black moves. Any help?
Kapil Gund
  • 19
  • 2
-3
votes
2 answers

How do you change a string to a list without separating all the characters?

I'm using the python-chess module to write a chess engine. Here's the code that I'm struggling with, for context: def move_search(): move_evals = [] legal_moves = list(board.legal_moves) for move in range (len(legal_moves)): …
user19770271
-3
votes
1 answer

How to detect who is move white or black in python-chess library?

I am created some chess program and want to detect who have move white or black. Which objects stores information which pieces will move Board, GameNode? import chess.pgn import chess.uci # ??? Board().is_white_move()? # ???…
Chameleon
  • 9,722
  • 16
  • 65
  • 127
1 2 3
8
9