Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
Activity
• 14:44
• 11:28
• 08:36
ScarecrowY closed #746
• 08:25
niklasf labeled #746
• 08:25
niklasf commented #746
• 08:23
niklasf labeled #746
• 08:17
ScarecrowY opened #746
• Mar 06 15:37
Johnne32 edited #745
• Mar 06 14:45
niklasf labeled #745
• Mar 06 14:27
Johnne32 opened #745
• Mar 04 19:23
• Mar 02 18:33
• Mar 02 14:37
ScarecrowY closed #744
• Mar 02 14:37
ScarecrowY commented #744
• Mar 02 14:35
niklasf commented #744
• Mar 02 14:31
ScarecrowY commented #744
• Mar 02 14:30
niklasf commented #743
• Mar 02 14:29
niklasf labeled #743
• Mar 02 14:28
niklasf commented #744
• Mar 02 14:26
niklasf labeled #744
Niklas Fiekas
@niklasf
so chess.Move.from_uci(message.content) raises ValueError
kdnune
@kdnune
Thanks for responding Niklas. I tried engine.configure({"Threads": 8}) , and the speed up was still barely noticeable. Again between about 3-4 minutes. I noticed from the task manager that the GPU was not being used at all for some reason. In my notebook, the line print("Num GPUs Available", len(tf.config.experimental.list_physical_devices('GPU'))) returns "Num GPUs Available 1", but it doesn't look like my GPU is actually being used. Is there any way I can actually utilize my GPU? Thanks again.
Niklas Fiekas
@niklasf
which chess.engine.Limit are you using?
what resources the engine uses is up to the engine itself. for example, stockfish is designed as a cpu engine and never uses gpu
kdnune
@kdnune
I used info = engine.analyse(board, chess.engine.Limit(time=1)). I'm using stockfish. I'm open to using other engines that would use the gpu. Do you know which engines would. Thanks.
Niklas Fiekas
@niklasf
lc0 would, but sf is the strongest engine there is, currently
time=1 means to spend 1 second to analyse the position, no matter what
so increasing threads was improving analysis quality, but still taking 1 second
you could chose a lower time (e.g. time=0.5), to trade quality for speed. there's also depth=20 or sth like that, or nodes=2100000 (just example values)
kdnune
@kdnune
OK, I'll have to play around a little bit more. I just tried setting the time = .01 and it finish just a couple seconds later. But this is probably giving too little time. Also thanks for the info that Lc0 would use the gpu. So far the only other engines I've tried are stockfish and komodo.
nmwitzig
@nmwitzig
Hey everyone, I have a question: I know that we can get the best move of the next player quickly by info['pv'][0], but I was wondering whether the second, third, fourth and so on best moves are stored already anywhere else. Currently, to get this info I loop through all legal moves, get the evaluation score and sort accordingly, but this is computationally very expensive. Glad for any other tips! Thanks!
Niklas Fiekas
@niklasf
sounds like you're looking for analyse(..., multipv=n). it has considerable extra cost, but is still better than looping through all legal moves
nmwitzig
@nmwitzig
Thanks! Ill give this a try!
Niklas Fiekas
@niklasf
currently the only reliable way is to track the state yourself
set a variable when you start it, and unset it when the command finishes
nmwitzig
@nmwitzig

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.

Thanks!
Niklas Fiekas
@niklasf
@nmwitzig don't think so. most uci engines should support 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
@PedanticHacker i maintain such a dataset at https://github.com/niklasf/eco, that you could write probing code for
nmwitzig
@nmwitzig
@niklasf Thanks for the prompt response! I think info[n]["score"] (with n \in 0,...,N-1) and multipv = N ) should suffice for my purpose! Best regards!
Niklas Fiekas
@niklasf
that's board.generate_legal_moves(from_mask=board.knights) etc.
Niklas Fiekas
@niklasf
yep. any square set or mask
Boštjan Mejak
@PedanticHacker
I have tested this and works great:
XX = """<g id="xx"><circle r="5" cx="22.5" cy="22.5" fill="#0000ff"></circle></g>""" # noqa: E501
Niklas Fiekas
@niklasf
you can do monkey patching (chess.svg.XX = ...) to achieve that, or insert the svg elements yourself
i don't want to change to that style, because the intended semantics are "cross out", not legal move hints like on lichess
Boštjan Mejak
@PedanticHacker
@niklasf, please fix the alignment of white and black pawns, because their offset from the center of a square on the x axis is exactly 0.5 pixels to the left.
nmwitzig
@nmwitzig

Hi everyone, I'm still looking for the best way to evaluate a given move by a player/engine.

Say I evaluate the base position at a given depth with multipv = 20 and get the evaluations for the best move, second best move and so on. The quality of a given move should be the difference between its evaluation and the evaluation of the best move in this setup, right?

Now I take any move of these 20 and limit the engine to only analyze this move (with root_moves= move and multipv=1) and ask for stockfish's evaluation of this move.

Why is this move now evaluated differently compared to the case of multipv=20?

thanks in advance! Im still struggling how to get measures of the quality of a move a player took.

Best regards

Boštjan Mejak
@PedanticHacker
There is a new project on GitHub named SuperChess. I'm very proud of it. Check it out HERE. SuperChess uses python-chess and PyQt5 to make it work. It's a chess GUI that uses the latest development build of Stockfish. I hope you'll like it. Help me make it even better, I'd really love any help or suggestion from you guys. Thanks!
Niklas Fiekas
@niklasf
@nmwitzig what's your search limit? for example, a multipv=1 search can go much deeper than a multipv=20 search in the same amount of time
nmwitzig
@nmwitzig
nmwitzig
@nmwitzig

Hi @niklasf , thanks for reaching out!

I appended a screenshot from the analysis using a fixed width (20), in which we can see the following:

1. using multipv some does change what is judged as the best move for White in the starting position (g1f3 vs c2c4) and the evaluation of this changes considerably (+38 vs +14)

2. If we pick any move (I just picked the ninth best move according to the multi pv evaluation), the evaluation of this move does not change very much. This is really nice as it may offer a fast way to evaluate not any random move but the move a player in a real game made, BUT since the evaluation of the best move changed, I obtain different results when constructing the final evaluation of the random move.

This leaves me puzzled, maybe someone here has dealt with this in the past and has an idea

Thanks!

Evan Landreneau
@TricolorHen061_gitlab

I have a simple question. I have this code:

import chess

board = chess.Board()
board.push(chess.Move.from_uci("e2e3"))
board.push(chess.Move.from_uci("f1c4"))
board.push(chess.Move.from_uci("d1f3"))
board.push(chess.Move.from_uci("f3f7"))
print(board.is_checkmate())

It prints False, which is odd because I did the 4 move checkmate thing and the game should be over, right? What am I doing wrong here?

Evan Landreneau
@TricolorHen061_gitlab
@niklasf
Evan Landreneau
@TricolorHen061_gitlab
I wasn't giving black a chance to move, that was the problem
Boštjan Mejak
@PedanticHacker
import chess
board = chess.Board()
board.push(chess.Move.from_uci("f1c4"))
print(board)
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . B . . . . .
. . . . . . . .
P P P P P P P P
R N B Q K . N R
Boštjan Mejak
@PedanticHacker
I just found out that you can turn any piece into a Spiderman that can jump over other pieces. Just like in my code above, White's bishop in the very first move jumps to c4, even though there's a pawn on e2 blocking it. This should not be possible!
Niklas Fiekas
@niklasf
Vigoxin
@Vigoxin
Hi, grateful for any help. So I’m struggling to understand something fundamental about how the chess engine works. Firstly, is stockfish deterministic? If you plug in the exact same position, assuming there isn’t a mate-in-x where x is less than the depth you’ve set in the limit, should it give you the same exact score? If not, then how come if I run the exact same script (which analyses a position once) multiple times, I always get the same answer, but if in the same script I analyse the same position multiple times sequentially then I get slightly different answers? I asked this on stackoverflow but I don’t think it’ll be solved: https://stackoverflow.com/questions/65994195/why-are-there-different-scores-when-chess-engine-analyses-a-position-multiple-ti
Niklas Fiekas
@niklasf
nmwitzig
@nmwitzig

Hi all, again me, I noticed another slightly strange behavior using root_moves =

As you can see in the screenshot, selecting a fixed depth of 20 doesn't result in the same number of "seldepth", which in turn, appears to influence the evaluation score of the same move.

Has anyone successfully evaluated many moves of real players in the past and figured out how to evaluate the moves correctly? In theory, a move should at best be evaluated around 0 (with a small randomness around 0)..

Best

nmwitzig
@nmwitzig
I saw a related recent question on stack overflow, if its better placed on SO there I can open an issue.
Niklas Fiekas
@niklasf
i think the answer might be exactly the same as to the question above
doing a second analysis benefits from the progress saved in the hashtable of the first
Vigoxin
@Vigoxin
Niklas, sorry I thought I replied before but I ddidnt. Just wanted to say thanks so much for answering my question!
Boštjan Mejak
@PedanticHacker
Since python-chess supports LAN (Long Algebraic Notation) and SAN (Standard Algebraic Notation) for writing chess moves, it doesn't support FAN (Figurine Algebraic Notation). Is this something that could happen?
Niklas Fiekas
@niklasf
i probably won't add it for now, but you can implement it using simple text replacement on SAN
9acca9
@9acca9
Hello.
Excuse the ignorance. With python-chess I can know at every moment what kind of movement was made? for example if it was a king or queen castling, if it was a pawn in passing. Is there a function that returns these values to me?
Niklas Fiekas
@niklasf
@9acca9 that should be possible with combinations of move.from_square / move.to_square and board.piece_at(...)