1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Use if instead of goto

This PR inverts the if and removes goto in the generate_all function.

closes https://github.com/official-stockfish/Stockfish/pull/3461

No functional change
This commit is contained in:
Prokop Randáček 2021-05-12 20:15:21 +02:00 committed by Joost VandeVondele
parent 038487f954
commit 6b9a70ace8
2 changed files with 14 additions and 14 deletions

View file

@ -175,6 +175,7 @@ Stefan Geschwentner (locutus2)
Stefano Cardanobile (Stefano80) Stefano Cardanobile (Stefano80)
Steinar Gunderson (sesse) Steinar Gunderson (sesse)
Stéphane Nicolet (snicolet) Stéphane Nicolet (snicolet)
Prokop Randáček (ProkopRandacek)
Thanar2 Thanar2
thaspel thaspel
theo77186 theo77186

View file

@ -192,21 +192,20 @@ namespace {
const Square ksq = pos.square<KING>(Us); const Square ksq = pos.square<KING>(Us);
Bitboard target; Bitboard target;
if (Type == EVASIONS && more_than_one(pos.checkers())) // Skip generating non-king moves when in double check
goto kingMoves; // Double check, only a king move can save the day if (Type != EVASIONS || !more_than_one(pos.checkers()))
{
target = Type == EVASIONS ? between_bb(ksq, lsb(pos.checkers()))
: Type == NON_EVASIONS ? ~pos.pieces( Us)
: Type == CAPTURES ? pos.pieces(~Us)
: ~pos.pieces( ); // QUIETS || QUIET_CHECKS
target = Type == EVASIONS ? between_bb(ksq, lsb(pos.checkers())) moveList = generate_pawn_moves<Us, Type>(pos, moveList, target);
: Type == NON_EVASIONS ? ~pos.pieces( Us) moveList = generate_moves<Us, KNIGHT, Checks>(pos, moveList, target);
: Type == CAPTURES ? pos.pieces(~Us) moveList = generate_moves<Us, BISHOP, Checks>(pos, moveList, target);
: ~pos.pieces( ); // QUIETS || QUIET_CHECKS moveList = generate_moves<Us, ROOK, Checks>(pos, moveList, target);
moveList = generate_moves<Us, QUEEN, Checks>(pos, moveList, target);
moveList = generate_pawn_moves<Us, Type>(pos, moveList, target); }
moveList = generate_moves<Us, KNIGHT, Checks>(pos, moveList, target);
moveList = generate_moves<Us, BISHOP, Checks>(pos, moveList, target);
moveList = generate_moves<Us, ROOK, Checks>(pos, moveList, target);
moveList = generate_moves<Us, QUEEN, Checks>(pos, moveList, target);
kingMoves:
if (!Checks || pos.blockers_for_king(~Us) & ksq) if (!Checks || pos.blockers_for_king(~Us) & ksq)
{ {
Bitboard b = attacks_bb<KING>(ksq) & (Type == EVASIONS ? ~pos.pieces(Us) : target); Bitboard b = attacks_bb<KING>(ksq) & (Type == EVASIONS ? ~pos.pieces(Us) : target);