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
2
votes
0 answers

Improving Stockfish computation to generate best possible move

I use the stockfish engine to generate the optimal moves in an simulated chess game. I use python-chess to integrate the Stockfish engine in my simulation. At the moment I set the depth of the search operation for the optimal move with…
sebko_iic
  • 340
  • 2
  • 16
2
votes
1 answer

PythonChess - Get engine to predict a list of the best moves in a position

I currently have a board, then on that I move my e2 pawn to e4. I'm looking for a way to get the engine to predict the X amount of best moves for black. I know how to predict the best move given a position: result = engine.play(board,…
user7020610
2
votes
1 answer

Python: Evaluating a board position using stockfish from the python-chess library

I am trying to create an engine but my evaluation function is terrible so I decided to use stockfish to evaluate it for me. import chess import chess.engine def stockfish_evaluation(board, time_limit = 0.01): engine =…
TheLizzard
  • 7,248
  • 2
  • 11
  • 31
2
votes
6 answers

Is there a way to convert a python chess board into a list of integers?

I am trying to create a neural network to play chess, but first, I need to convert the chess board to a list of integers. I am using the python-chess module for the chess board and game. I currently have a chess board class, but cannot find a method…
Monolith
  • 1,067
  • 1
  • 13
  • 29
2
votes
1 answer

python canvas create image in loop

Hello i recently started studying tkinter and decided to pick up chess board game. Below is my code: import tkinter as tk class GameBoard(tk.Frame): def __init__(self, parent, rows=8, columns=8, size=70, color1="white", color2="blue"): …
Aj06
  • 79
  • 1
  • 15
1
vote
0 answers

Unable to make a python-chess engine communicating with Arena GUI

I've been trying to make a custom python engine, that uses UCI protocol to communicate it's moves. I'm able to understand how the UCI protocol works, but I don't understand how to make my python engine script communicate with the Arena GUI. I can…
1
vote
1 answer

How to fix LegalMoveGenerator "LegalMoveGenerator object is not callable" error in python-chess?

I am trying to make a chess Minimax algorithm. However, I encountered a problem. This is my code: import random import itertools from chess import Board, Move, LegalMoveGenerator def legal_move_to_move(legal_move): """ Converts a…
1
vote
0 answers

genrating sliding piece moves on bitboard efficiently without magic bitboard

I'm currently working to improve a chess engine in python. more specifically I'm working on the move generation of sliding pieces, like rooks and bishops. originally I used this loop function for both rook and bishop moves: def get_rook_moves(self,…
Smillyone
  • 11
  • 1
1
vote
1 answer

Extracting data from PGN files

I trying to extract move information and annotations from a few PGN files, outputting to a text file. My current code is: import chess.pgn import io import os def handle_san_error(pgn_file, game_str, san_error): # Skip the problematic move …
1
vote
1 answer

Python chess search function: pop from empty list

This is my search function for python chess engine: def search(pos: position.Position, depth: int, alpha: int, beta: int, side_to_move: chess.Color, root: bool = False): global nodes, best_score, best_move, max_score, min_score, killers …
Boo Who
  • 17
  • 6
1
vote
1 answer

How to load a complex SVG into pygame correctly?

I am making a chess game in Python with PyGame using the python-chess library. When I implement my program in PyGame the window only shows the empty board without the pieces. However, if I manually open the svg file that my code generates it shows…
Rey Fit
  • 15
  • 4
1
vote
1 answer

Exporting Chess moves and images into HTML or CSV format

I have used the post (Printing individual moves with the python-chess library) to obtain the individual moves and display image of the chess board. See the code below. import chess from io import StringIO import chess.pgn #create a virtual…
Arun Menon
  • 181
  • 8
1
vote
2 answers

How to do the reversed eight queen problems (check if any pair can eat ea other)?

Give the position of 8 queens on the chessboard. Print YES if at least one pair of queens hit each other. If not print out NO. so here's my code but when checking if these queens can hit ea other diagonally, python says unsupported operand type(s)…
Codeer
  • 82
  • 9
1
vote
2 answers

Getting Errno 13: Permission Denied as a root user

So basically, I just want to load chess engine which is in the same folder with script _, engine = await chess.engine.popen_uci('./engine') What is wrong with this? I am running the script as a root user. Also, if I load from just 'engine', it says…
Exenifix
  • 71
  • 1
  • 7
1
vote
1 answer

Why pieces are moving in opposite direction in python-chess

I have the following fen RNBK1B1R/PPPPQPPP/5N2/3pP3/4p1p1/2n2n2/ppp2p1p/r1bkqb1r b which is generated from a image recognition technique. This fen is based on a flipped board such that the black pieces are at the bottom. When I check the…
beta green
  • 113
  • 10
1
2
3
8 9