Questions tagged [python]

Python is a general purpose and high level programming language. You can use Python for developing desktop GUI applications, websites and web applications.

Filter by
Sorted by
Tagged with
12
votes
1answer
4k views

How to convert PGN moves to long algebraic notation (in python)?

I want to read a PGN file and then advance to a certain move number, and feed that to an UCI engine. Turns out engines work using long algebraic notation, and PGNs are in short algebraic. What is an ...
4
votes
2answers
1k views

Looking for a Python chess engine

I am looking for a Python chess engine package. It must be fully contained in Python, I don't want to download separate files for the engine itself and link them up somehow. All I want it to be able ...
4
votes
2answers
938 views

Python and UCI engine

I'm working with Stockfish in Python 3. And when I do something like this: I get just "bestmove e2e4". How can I retrieve full information? Like this:
4
votes
3answers
2k views

Play chess in Python programming language?

I am searching for a program/library in Python which will let two users or a user and an AI play chess with each other. PS: I have found python-chess. Can this be used for the above along with a ...
3
votes
1answer
130 views

How can I increase the search ply depth of my minimax function for my chess engine?

I have programmed a minimax function with alpha-beta pruning for a chess engine I am building. However, it is very slow and I cannot analyze to a deeper depth as it would take too much time. I believe ...
3
votes
1answer
339 views

Python-chess : Are the move scores enough to rank moves from the most to least likely moves played by an engine?

My goal is to make a script to finding the most and least likely move an engine will play, and then make a list it. I tried using the scores to make such a list, with the best score equalling the most ...
3
votes
1answer
1k views

Python-chess : how to get a list for the best engine moves

I am working on a simple cheat detection script to find if a user used one of the top engine moves in a game, so I found this great python-chess library Additionally, I found this example to getting ...
3
votes
1answer
305 views

Python script to let stockfish selfplay 10 games from a given position

I would like to have Stockfish to selfplay 10 games starting from a given position. Game should end after 10 moves. From the python-chess documentation there is an example of playing only one such ...
2
votes
1answer
413 views

Is there Python code to use the Leela neural network?

I am interested in doing some analyses of chess games using the neural network trained for Lc0. To that end I need to be able to turn PGN into the right kind of input vectors and to load and use the ...
2
votes
1answer
62 views

Unable to run Stockfish on Python

I know this isn't a programming forum, though it's chess-related, hence the placement on here. Basically, I'm trying to setup stockfish with Python on my PC. I installed it via pip install stockfish. ...
2
votes
1answer
103 views

Chess Engine with Python-Based / API?

I went through the most popular chess engines, e.g. StockFish, Komodo, Rykba and so forth, but I wasn't able to a.) find an API or b.) a python based Engine - does anyone know a suitable project? I ...
2
votes
2answers
233 views

How to install chess.pgn on python?

I don't know how to import chess.pgn on Python. I searched everywhere, but I didn't find anything. Can anybody here help me?
2
votes
1answer
72 views

What's the best way to get the top n engine moves?

I want to use python-chess to get the top 5 Stockfish moves from a given position with a numerical evaluation for each move. Is it more accurate to run the engine for 10 minutes with MultiPV=5, or to ...
2
votes
2answers
114 views

Export KPvK endings positions (up to black/white symmetry) from ChessBase 15 using python-chess

I have the Mega Database 2020 from ChessBase and ChessBase 15. I am using ChessBase 15 to search the Mega Database 2020, my search criterion being all games ended through a KPvK (king and pawn vs. ...
2
votes
3answers
298 views

How to use Arena GUI outputs in a python program

I'm currently developing a self-playing chessboard on which I'd like to implement an Artificial Intelligence (AI) (currently it's Stockfish. I would like to know how I could, if I can, export Arena ...
2
votes
1answer
141 views

How can I get multiple computer recommended lines in python-chess module?

In python-chess you can communicate with the engine on a given position. However the method presented in https://python-chess.readthedocs.io/en/latest/uci.html using the engine.go() function with only ...
2
votes
1answer
129 views

Quickly converting board to bitboard representation using python-chess library

I would like to convert a given chess board into its bitboard representation, but my implementation is rather slow. Here is what I'm doing (using the python-chess package): board = chess.Board('...
2
votes
1answer
314 views

Communication with Stockfish engine via Python

I try to access the Stockfish engine via Python, but only get bestmove = a2a3. If I enter the same commands into the MAC-terminal, the engine calculates the correct move. Can anyone help me, please ?...
2
votes
1answer
128 views

How can I send a UCI command to a chess engine in Python?

I have a followup question to my previous thread: Python script to let stockfish selfplay 10 games from a given position There are some engines that allow you to set a command that imposes that the ...
2
votes
1answer
204 views

Python Engines to Beat to Take the Crown

Since Python is extremely slow, chess engines are almost never written using it. I've been building a Python engine to avoid this issue (through JIT compilation), and want to compare my engine ...
2
votes
1answer
66 views

Question on how to access a move on a line outside the main line using python-chess

I'm trying to write a simple code that is capable of reading a PGN file and searching for moves and comments throughout the variant tree. However, I have not been successful, I have not yet been able ...
1
vote
3answers
243 views

Python-chess is_zeroing and is_capture operation outputs

I'm using python-chess to analyze a game. I have my code like this, and I expect 3 boolean outputs. print("is_castling: " + unicode(board.is_castling(node.move))); print("is_zeroing: " + unicode(...
1
vote
1answer
131 views

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

Say that I currently have a board, and then on that board 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 ...
0
votes
1answer
1k views

Why can't I use my stockfish engine with python chess? [closed]

I'm using python chess and I'm trying to use my stockfish 10 engine downloaded from the stockfish website. import chess.uci engine = chess.uci.popen_engine(r"stockfish-10-linux/Linux/...
0
votes
1answer
316 views

Python and Stockfish [duplicate]

I am trying to get Stockfish to work in Python 3. Just to get started on my project, I tried to have Stockfish think until a depth of 20. However, the program instantly returns that Stockfish ...