Position Causes Stockfish and Komodo To Crash

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Michel
Posts: 2219
Joined: Sun Sep 28, 2008 11:50 pm

Re: Position causes StockFish and Komodo to crash.

Post by Michel » Tue Dec 22, 2020 7:57 pm

Ajedrecista wrote:
Tue Dec 22, 2020 7:07 pm
Hello again:
Michel wrote:
Tue Dec 22, 2020 6:37 pm
Thanks. It seems I was wrong. In your position SF does find the ep move. Then I wonder why it does not consider the ep move in the parentless position...
The key could be in movegen.cpp. There is a three-line comment at current lines 159-161:

Code: Select all

// An en passant capture can be an evasion only if the checking piece
// is the double pushed pawn and so is in the target. Otherwise this
// is a discovery check and we are forced to do otherwise.
Which might explain the feature. A programmer opinion is valuable since I am not a programmer.

Regards from Spain.

Ajedrecista.
Thanks. That explains it, it seems. In order to find the ep move in the parentless positions (which some people will regard as illegal) SF would have to do a little bit more work in every position in check with an ep square.

I strongly doubt that this micro optimization brings any Elo.
Last edited by Michel on Tue Dec 22, 2020 8:05 pm, edited 1 time in total.
Ideas=science. Simplification=engineering.
Without ideas there is nothing to simplify.

Michel
Posts: 2219
Joined: Sun Sep 28, 2008 11:50 pm

Re: Position causes StockFish and Komodo to crash.

Post by Michel » Tue Dec 22, 2020 8:04 pm

Joerg Oster wrote:
Tue Dec 22, 2020 7:55 pm
Michel wrote:
Tue Dec 22, 2020 7:48 pm
Joerg Oster wrote:
Tue Dec 22, 2020 6:55 pm
Michel wrote:
Tue Dec 22, 2020 6:37 pm
Thanks. It seems I was wrong. In your position SF does find the ep move. Then I wonder why it does not consider the ep move in the parentless position...
Why generating an illegal move?
Why do you consider the ep move illegal?
Because this kind of move can NEVER occur in a legal game of chess.
So I can only conclude it must be an illegal move.

The illegal position makes it look like a valid move, doesn't it? :D
Whether you consider such a position as legal or not is a matter of definition. I would regard it as legal.

Do you think engines (or GUIs) should refuse on principle to play the wild/5 starting position on FICS, simply because it cannot be reached from the official starting position?
Ideas=science. Simplification=engineering.
Without ideas there is nothing to simplify.

User avatar
MikeB
Posts: 4734
Joined: Thu Mar 09, 2006 5:34 am
Location: Pen Argyl, Pennsylvania

Re: Position causes StockFish and Komodo to crash.

Post by MikeB » Tue Dec 22, 2020 10:23 pm

Michel wrote:
Tue Dec 22, 2020 8:04 pm
Joerg Oster wrote:
Tue Dec 22, 2020 7:55 pm
Michel wrote:
Tue Dec 22, 2020 7:48 pm
Joerg Oster wrote:
Tue Dec 22, 2020 6:55 pm
Michel wrote:
Tue Dec 22, 2020 6:37 pm
Thanks. It seems I was wrong. In your position SF does find the ep move. Then I wonder why it does not consider the ep move in the parentless position...
Why generating an illegal move?
Why do you consider the ep move illegal?
Because this kind of move can NEVER occur in a legal game of chess.
So I can only conclude it must be an illegal move.

The illegal position makes it look like a valid move, doesn't it? :D
Whether you consider such a position as legal or not is a matter of definition. I would regard it as legal.

Do you think engines (or GUIs) should refuse on principle to play the wild/5 starting position on FICS, simply because it cannot be reached from the official starting position?
That is the programmer's choice (GUI and Engine) , not the user's choice. Regardless of principle, it is up to the user to find an engine that plays wild/5 if that is his desire.
Image

syzygy
Posts: 5000
Joined: Tue Feb 28, 2012 10:56 pm

Re: Position Causes Stockfish and Komodo To Crash

Post by syzygy » Tue Dec 22, 2020 10:44 pm

Michel wrote:
Tue Dec 22, 2020 9:36 am
An interesting issue here https://github.com/official-stockfish/S ... ssues/3270

SF move generation assumes (correctly it seems) that in a game an escape move can never be an ep move. But of course one can create positions (without parent) in which there is an escape move which is indeed an ep move.

Since the position is illegal, who is to say that the generated set of moves is incomplete? We can simply define that the ep move is illegal for this illegal position.

More "serious" are illegal positions which trigger undefined behaviour.

Btw, ep moves in legal positions can be escape moves, and SF generates those.

syzygy
Posts: 5000
Joined: Tue Feb 28, 2012 10:56 pm

Re: Position causes StockFish and Komodo to crash.

Post by syzygy » Tue Dec 22, 2020 11:27 pm

Ajedrecista wrote:
Tue Dec 22, 2020 7:07 pm
The key could be in movegen.cpp. There is a three-line comment at current lines 159-161:

Code: Select all

// An en passant capture can be an evasion only if the checking piece
// is the double pushed pawn and so is in the target. Otherwise this
// is a discovery check and we are forced to do otherwise.
Which might explain the feature. A programmer opinion is valuable since I am not a programmer.
The "and we are forced to do otherwise" part seems a bit puzzling.

Let's see. If the position has ep rights, the checking move must be the double pawn push (e.g. d2d4). Like any other regular move, a double pawn push gives check either by attacking the enemy king with the piece that is moved or by unblocking a sliding attack at the enemy king (discovered check).

If the pawn attacks the enemy king, an en passant capture is a potentially legal evasion move and should therefore be generated.

If the double pawn unblocked a sliding attack, an en passant capture can be an evasion move only if it blocks the sliding attack. This can only be the case if the en passant square (e.g. d3) blocks the same sliding attack that was blocked by the original square of the doubly-pawn-pushed pawn (d2). But if these squares (d2 and d3) blocked the same sliding attack, it was also still blocked by the doubly-pawn-pushed pawn at its destination square (d4). In other words, an en passant capture can never evade a discovered check.

Sesse
Posts: 284
Joined: Mon Apr 30, 2018 9:51 pm
Contact:

Re: Position causes StockFish and Komodo to crash.

Post by Sesse » Tue Dec 22, 2020 11:43 pm

Michel wrote:
Tue Dec 22, 2020 7:57 pm
I strongly doubt that this micro optimization brings any Elo.
It's been there since the very first Stockfish commit (import of Glaurung 2.1). Perhaps this is a good chance to get a commit in as a simplification? =)

Post Reply