Prevents generation of illegal castling moves.
Example: reb2rk1/ppppqppp/2nb1n2/4p3/4P3/N1P2N2/PB1PQPPP/RE2KBHR[h] w KQacgh - 3 7
if (gating() && gates(WHITE))
for (File f = FILE_A; f <= max_file(); ++f)
- if (gates(WHITE) & file_bb(f))
+ if ((gates(WHITE) & file_bb(f)) && count_in_hand(WHITE, ALL_PIECES))
ss << char('A' + f);
if (can_castle(BLACK_OO))
if (gating() && gates(BLACK))
for (File f = FILE_A; f <= max_file(); ++f)
- if (gates(BLACK) & file_bb(f))
+ if ((gates(BLACK) & file_bb(f)) && count_in_hand(BLACK, ALL_PIECES))
ss << char('a' + f);
if (!can_castle(ANY_CASTLING) && !(gating() && (gates(WHITE) | gates(BLACK))))