159 questions
1
vote
0
answers
79
views
xml in chess pgn using python
<line fen="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1">
<move m="e4"/>
<move m="e5"/>
<move m="d4"/>
<...
1
vote
0
answers
111
views
NotImplementedError using chess.engine.SimpleEngine.popen_uci in Jupyter Notebook
All versions are up to date:
Windows 11,
Python 3.13.5,
Jupyter:
IPython : 9.4.0
ipykernel : 6.30.0
ipywidgets : not installed
jupyter_client : 8.6.3
jupyter_core : 5.8.1
...
0
votes
1
answer
67
views
Why the python chess engine time goes downward Although the engine is running constantly without stopping?
When i tried this code in my main project to get infinite analysis in my chess GUI (I wanted the engine to think infinitely about a position and give its data (score, best move, etc..) and no depth or ...
2
votes
1
answer
171
views
Chess FEN in python chess and chess js
I wrote my chess openings database using python chess lib and now I'm trying to use it as an api on a website to determine the position name. But python chess and chessjs use different methods to ...
1
vote
1
answer
263
views
Python chess engine is too slow
I have a working 1600 blitz level bot but it works too slow in python using python chess library. I tried to optimize the functions in eval function but the best it can do is depth 4 since it takes a ...
-1
votes
1
answer
78
views
how to update timer every second in Tkinter label for chess GUI?
I have made a simple chess GUI with tkinter. Now I want to add a clock for each player.
The clock is displayed in a label's text. It works in human player's turn. The time changes every second. When ...
1
vote
1
answer
269
views
strange mistake when using Python chess library, after set.fen() and push(move), board.legel_moves generates wrong moves
I am writing a small chess GUI with Python chess library. Yesterday, I ran my code a lot of times without any problem. Then I installed some other Python libraries. Today I noticed a strange mistake: ...
2
votes
3
answers
270
views
Extracting non-standard evaluation scores from PGN comments using python-chess
I have a PGN file, which is an output of Cute Chess.
1. e4 {+0.42/27 1.6s} e5 {-0.21/26 5.4s}
2. Nf3 {+0.34/22 0.94s} Nc6 {-0.16/19 0.37s}
3. Bb5 {+0.35/27 2.1s} Nf6 {-0.19/26 0.80s}
4. O-O {+0.33/...
-1
votes
1
answer
253
views
parsing moves from pgn
i have a service, that gets a game from database and adding moves to it. also, it edits current pgn (string of moves).Is there any functions, that can get given string of moves and parse moves from it?...
-5
votes
1
answer
48
views
How can i convert python project into exe file with directory [duplicate]
I made python project for my university. It is kinda big, has stockfish in its content
How can i make an exe game?
I tried auto-to-py exe and it didt work (maybe because of this PyTask_chess/PyTask/...
-1
votes
1
answer
51
views
while reading a value by using a for loop it gives me this error (ValueError: invalid literal for int() with base 10: '')
I am trying to make a chess game that can be ran on terminal and a variable that should have a value doesn't have a value and i don't know what is that cousing the problem
I want to make a chess ...
0
votes
1
answer
65
views
TimeoutError with python-chess when trying to initialize Stockfish on macOS
I'm trying to use the python-chess library to interface with Stockfish on macOS, but I'm encountering a TimeoutError during the initialization process. Here's a simplified version of my code:
import ...
0
votes
0
answers
122
views
New figures on the Chess-Python-Board
I want to add to my Python Chess Endgame Engine 3 new figures:Amazon, Bob and Cyryl.Amazon moves like knight and bishop,Bob as a rook and knight
and Cyryl as Queen and Knight. I have code like this.
...
0
votes
1
answer
60
views
How would I convert the output of a keras model into a chess move?
My model was trained off of thousands of FENs which are simply chess positions and the move that was played as a response to that chess position. The model should output a predicted move in response ...
0
votes
1
answer
67
views
Python Chess Engine: How do I replace the piece thats on the inputted square with a "#"?
When the user inputs a coordinate like "a1", I want to find the piece that is on that square and replace its icon with a "#" character and render the new board. So the rook in the ...
0
votes
0
answers
68
views
create_image parameter image error: _tkinter.TclError: image "pyimage1" doesn't exist
Hello I am trying to display a chess board and when I get to the create_image part I am getting the following issue:
Exception has occurred: TclError image "pyimage1" doesn't exist File &...
2
votes
0
answers
111
views
chess endgame engine is not working completely correctly
I have proceeded a bit with my goal to obtain a chess-game endgame engine where both players would play fully optimally while there are D<5 pieces on the board so that I can wait for the result.The ...
2
votes
1
answer
84
views
Quiescense search problems
Im currently working on a chess engine in python using the chess library. I have attempted to implement a quiescense search by using the pseudocode from the chess programming wiki, but once I run the ...
0
votes
1
answer
197
views
How can I speed up my training time for a python-chess bot using ppo?
I am attempting to build a chess bot which learns using Proximal Policy Optimization. I am currently using the python-chess library (https://python-chess.readthedocs.io/en/latest/index.html#) as the ...
4
votes
0
answers
464
views
chess endgame engine in Python doesn't work perfectly
I'm trying to create a code for perfectly optimal chess endgame.
By that I mean that the loosing player tries to delay the checkmate as long as possible while the winning tries to checkmate the ...
0
votes
0
answers
170
views
Why augmented_corners is not defined
I have forked code from GitHub that provided about Play online chess with real chess board.
But I found the error below:
Traceback (most recent call last):
File "board_calibration.py", ...
0
votes
0
answers
81
views
chess endgame: a problem with propagation upwards for a fully optimal game
Can you fulfill all these 13 points at simultaneously:
chess endgame: a problem with propagation upwards for a fully optimal game
I do not know what to add so that my question would become accepted ...
1
vote
0
answers
50
views
The Reti endgame
I'm trying to make my code in Python to solve correctly the Reti endgame by pushing Kh8 to Kg7, which is the only move leading to a draw for white. However the code given below keeps saying
Positions ...
1
vote
1
answer
235
views
Trying to create an endgame chess engine fully on my own in Python. Keeping getting AssertionError: san() and lan() expect move to be legal or null
I'm trying to create an endgame chess engine fully on my own and in Python. I'm keeping getting an error as below. I'm unable to get rid of it. Can someone kindly fix it or give me a hint how to fix ...
0
votes
1
answer
163
views
Chess endgame engine built on my own with BFS algorithm and dictionary data structure
I was using ChatGPT4 for creating a chess code for the problem stated below,
but mostly I was not obtaining any results beyond "depth 0 up to depth 19" with the number of positions searched....
0
votes
0
answers
85
views
The Python code I created using Python and Tensorflow does not work as I want
I wrote two codes, one of which generates random moves, evaluates them with Stockfish, and then trains them to create a model. Other code for using this model and playing with it.
import chess
import ...
0
votes
0
answers
248
views
python-chess stockfish analysis died unexpectedly
I'm trying to get position evaluation using Stockfish on python-chess. From a total of 1 million FEN position, Stockfish will return the score. However, after the 25430th position (oddly specific), ...
2
votes
0
answers
127
views
Chess Backtracking solution for endgames
I have the following backtracking solution to chess endgames with D=3 figures on the board.
I should have obtained white king to move on Kc2, but I'm getting Qh3h8.
I have printed the print(board....
0
votes
0
answers
135
views
How to print second best move in python-chess, along with first bes move
I'm currently trying to create a program using Python-Chess that will analyse games for me, and give a list of best, and second best moves. Even though lichess.org and chess.com have good UI for this, ...
0
votes
1
answer
130
views
my chess engine search is returning nothing
when I get out of book in my chess engine, it is returning none.
import random
import chess
import chess.polyglot
import time
from evaluate import *
max_depth = 18
move_points = []
def nextMove(...
1
vote
0
answers
71
views
Script for Chess GUI not loading the right images when execute?
I have this simple code using Python that will allow me to play chess against Stockfish. I also implemented a simple GUI that helps visualize the pieces easier. I have name the black pieces images &...
0
votes
1
answer
330
views
Wrong FEN evaluation with stockfish
I am trying to evaluate a FEN position with stockfish.
Given this position:
rnbqkbnr/pppp1p1p/8/4p3/P3P1p1/5N2/1PPP1PPP/RNBQKB1R b KQkq - 0 4 and stockfish 16.
This is the position board picture:
I ...
1
vote
1
answer
136
views
Best Way to Debug html5lib.html5parser.ParseError: Unexpected character after attribute value"?
I am currently working on a personal project and utilizing the chessdotcom Public API Package. I am currently able to store in a variable the PGN from the daily puzzle (Portable Game Notation) which ...
0
votes
0
answers
100
views
How to speed up classes and objects in python, related to move generation for a chess engine
I’m in the beginnings of creating a chess engine written in python and I was wondering of ways to improve the move generation part. Generating pseudo-legal moves I can do about 30/40 K moves/s on my ...
0
votes
3
answers
656
views
Can't make Python Stockfish weaker
I’ve written a chess software in Python which use Stockfish via this library:
https://pypi.org/project/stockfish/
The software works and plays well. Too well actually…
Mi idea was the app can offer a ...
0
votes
0
answers
183
views
why does this minimax algorithm output the same moves every time no matter what?
I'm trying to make a simple chess AI in python but when I try to play a game using this algorithm to find the best move it outputs the same thing every time (Nh6, Rg8, Rh8, Rg8...).
# Minimax ...
-1
votes
1
answer
157
views
How to use Python multiprocessing library in a chess search algorithm?
I am currently working on a chess engine, and I am looking at parallelization as a way to optimize the time it takes to search legal moves to find the best one. I found the Python module ...
0
votes
1
answer
88
views
Looking to create a simple chess game, getting stuck
I need help setting up the write logic for the winning condition
"The game end when either player's king reaches row 8, unless it is white's turn and black's king is in row 7, then black has one ...
1
vote
0
answers
149
views
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 ...
1
vote
1
answer
102
views
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 ...
1
vote
0
answers
151
views
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 ...
0
votes
1
answer
331
views
What does stockfish.py log as a move when promoting?
So I was just messing around with the stockfish library and am converting the moves to a PGN text format and errored parsing the move
Right now every move comes in this format "a1b2" and I'm ...
1
vote
0
answers
48
views
can negamax be implemented for 4 player chess?(bughouse)
I am seeing that negamax is often used for chess engines.However there is only popular instances of it being used in the conventional game.Is negamax good for the variants of chess like bughouse or is ...
0
votes
1
answer
233
views
Using python tkinter, how do I make buttons invisible?
As someone who is relatively new to coding, I am trying to create my own chess game. Currently, I am facing a challenge in attempting to make my buttons invisible while still allowing them to execute ...
1
vote
1
answer
456
views
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, ...
-1
votes
1
answer
288
views
who to start as black in stockfish python
I'm trying to start the Stockfish module in Python as the black player instead of the default white. I've been looking for parameters or other information on how to do this, but haven't been able to ...
1
vote
1
answer
158
views
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, ...
-2
votes
1
answer
261
views
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: ...
0
votes
1
answer
105
views
Failure to properly load a chess board in Pygame
I am attempting to create a chess GUI. I was able to make it so that when the player is White, everything loads perfectly. However, when I try to load when the player is Black, it does not load ...
1
vote
2
answers
869
views
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 ...