Stockfish: Atomic960 castling with b rook shielding attack from a file

Created on 21 May 2017  路  5Comments  路  Source: ddugovic/Stockfish

This doesn't have very high priority, since Atomic960 is rather rare. Input:

setoption name uci_variant value atomic
setoption name uci_chess960 value true
position fen 8/8/8/8/8/8/2k5/rR4K1 w Q - 0 1
d
perft 1

Output:

Stockfish 140517 64 BMI2 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott

 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 |   |   | k |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 | r | R |   |   |   |   | K |   |
 +---+---+---+---+---+---+---+---+

Fen: 8/8/8/8/8/8/2k5/rR4K1 w B - 0 1
Key: 241D8337F3F980E1
Checkers: 

Position: 1/1
b1a1: 1
b1c1: 1
b1d1: 1
b1e1: 1
b1f1: 1
g1h2: 1
g1g2: 1
g1f2: 1
g1h1: 1
g1f1: 1

===========================
Total time (ms) : 7
Nodes searched  : 10
Nodes/second    : 1428

Expected: After castling kings are touching, so the attack from a1 is irrelevant. g1b1 should be legal.

The problem is likely due to this check: https://github.com/ddugovic/Stockfish/blob/master/src/movegen.cpp#L66-L70

Most helpful comment

I found a couple other interesting positions:
Atomic - 8/8/8/8/8/8/5k2/R3K2r w Q -
Atomic960 - 8/8/8/8/8/8/7k/R5Kr w Q -

I assume that the king moves first, and as it moves (through each square) it cannot move through check (unless adjacent to the opposing king); then the rook moves.

All 5 comments

Ah, interesting... it's probably worth considering how the "cannot move out of, through, or into check" applies in this situation (versus the king starting on d1).

I found a couple other interesting positions:
Atomic - 8/8/8/8/8/8/5k2/R3K2r w Q -
Atomic960 - 8/8/8/8/8/8/7k/R5Kr w Q -

I assume that the king moves first, and as it moves (through each square) it cannot move through check (unless adjacent to the opposing king); then the rook moves.

SSCCE test case should produce the same results as c0c73eb:

setoption name UCI_Variant value atomic
position fen 8/8/8/8/8/8/5k2/R3K2r w Q - moves e1c1
d

setoption name UCI_Variant value atomic
position fen 8/8/8/8/8/8/4k3/R3K2r w Q - moves e1c1
d

setoption name UCI_Variant value atomic
position fen 8/8/8/8/8/8/3k4/R3K2r w Q - moves e1c1
d

setoption name UCI_Variant value atomic
setoption name UCI_Chess960 value true
position fen 8/8/8/8/8/8/3k4/rR2K3 w Q - moves e1b1
d

setoption name UCI_Variant value atomic
setoption name UCI_Chess960 value true
position fen 8/8/8/8/8/8/4k3/rR2K3 w Q - moves e1b1
d

I have written a fix that tries to eliminate special cases: https://github.com/ianfab/Stockfish/commit/2aaaa84e25216a83431264f48d16a2b46306d415. Since the variant is a template parameter at this point, I guess there is no performance issue.

Excellent and much cleaner than both of my overly complex attempts. I overlooked that we could bitmask using both king and rook, thereby not needing to check the Chess960 flag.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ppigazzini picture ppigazzini  路  14Comments

Nordlandia picture Nordlandia  路  13Comments

Truthdoc picture Truthdoc  路  12Comments

ddugovic picture ddugovic  路  10Comments

Vinvin20 picture Vinvin20  路  9Comments