niklasf on master
Test king captures unmoved rook (compare)
niklasf on master
Read and write millisecond %clk… (compare)
I'm designing a variant chess game with modifications to existing pieces' moves and play it on 5x5 Minichess board. Are such custom pieces and board layouts supported by python-chess, and how do I implement them without changing the library?
The custom pieces are:
(1) ♝ Crusaders (modded Bishops) ♗:
(2) ♞ Horse Archers (modded Knights)♘:
The custom boards are Gardner and Mallett under the 5×5 chess section here:
My GitHub fork (mostly built on someone else's) currently has a weakly-working AI playing standard pieces and board layouts:
Thank you in advance and looking forward to your response.
Warmest regards from my country Taiwan,
Vel (Tien-Yun) Wu
0 1 0.4385 1 white 1
j expectation gamenbr movecolor movenbr
I'm sorry because I'm not sure if this is the right place for this, but I get the error "ValueError: 'pl' is not in list" in a file from python-chess. i am not sure exactly what this is doing but I think it could be causing an issue with changing the orientation of the board, as after I try to do that, after a few times this error occurs. Here is the full error if this helps.
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\ethan\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 333, in _run_event
await coro(args, *kwargs)
File "D:\Documents\chess\main.py", line 82, in on_message
if chess.Move.from_uci(message.content) in board.legal_moves:
File "C:\Users\ethan\AppData\Local\Programs\Python\Python38\lib\site-packages\chess__init__.py", line 522, in from_uci
from_square = SQUARE_NAMES.index(uci[0:2])
ValueError: 'pl' is not in list
time=1means to spend 1 second to analyse the position, no matter what
time=0.5), to trade quality for speed. there's also
depth=20or sth like that, or
nodes=2100000(just example values)
I have a question. What's the simplest way to check whether a chess engine has been stopped? I noticed this "stopped" attribute throughout the engine.py module. Is that just for internal use or can it be used as a way to check whether a chess engine has been stopped? And if yes, can it be used as engine.stopped (where engine is an instance of chess.engine.SimpleEngine)?
So, I am using the chess.engine.SimpleEngine instance and have implemented a way to stop the engine by using its close() method. To restart it, I have found a way, but I need to check whether the engine has been stopped before restarting it. What's your best solution?
I initially thought chess.polyglot is what I need, but I don't think I can get an opening name for a certain board position with it. Please correct me if I'm wrong.
So what I want is that if moves "1.e4 e5 2.Nf3 Nc6 3.Bb5" have been played, the opening name "Ruy Lopez / Spanish Opening" should appear. So what can I do or use to classify such move orders and give them names?
sounds like you're looking for
analyse(..., multipv=n). it has considerable extra cost, but is still better than looping through all legal moves
Thanks again for this hint, works like a charm! But another question: Often, we are interested in the evaluation of the engine for a given move.
I know how to analyze a position and some scientific papers simply use formulas such as evaluation_after_a_move - evaluation_before_move (with correct presigns etc.) to obtain the score of a given move a player made.
However, is there an easier way to obtain scores for given moves? Thanks to multipv=3 i can get the three best engine moves, but I'd like to have a more nuanced picture how the engine actually rated each possible move.
root_moves(https://python-chess.readthedocs.io/en/latest/engine.html#chess.engine.Protocol.analysis), but essentially it's not better than making the move and analysing that position