mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 09:37:16 +08:00
Remove Condition from Generate_Move Loop
it seems it's faster to handle blockers_for_king(~Us) outside loops
Passed STC:
LLR: 2.96 (-2.94,2.94) {-0.25,1.25}
Total: 22184 W: 2063 L: 1919 D: 18202
Ptnml(0-2): 63, 1485, 7855, 1623, 66
https://tests.stockfishchess.org/tests/view/5ffbee2f6019e097de3ef18d
closes https://github.com/official-stockfish/Stockfish/pull/3299
No functional change
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -33,6 +33,7 @@ Bill Henry (VoyagerOne)
|
|||||||
Bojun Guo (noobpwnftw, Nooby)
|
Bojun Guo (noobpwnftw, Nooby)
|
||||||
braich
|
braich
|
||||||
Brian Sheppard (SapphireBrand, briansheppard-toast)
|
Brian Sheppard (SapphireBrand, briansheppard-toast)
|
||||||
|
Bruno de Melo Costa (BM123499)
|
||||||
Bryan Cross (crossbr)
|
Bryan Cross (crossbr)
|
||||||
candirufish
|
candirufish
|
||||||
Chess13234
|
Chess13234
|
||||||
|
|||||||
@@ -175,25 +175,19 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<Color Us, PieceType Pt, bool Checks>
|
template<PieceType Pt, bool Checks>
|
||||||
ExtMove* generate_moves(const Position& pos, ExtMove* moveList, Bitboard target) {
|
ExtMove* generate_moves(const Position& pos, ExtMove* moveList, Bitboard piecesToMove, Bitboard target) {
|
||||||
|
|
||||||
static_assert(Pt != KING && Pt != PAWN, "Unsupported piece type in generate_moves()");
|
static_assert(Pt != KING && Pt != PAWN, "Unsupported piece type in generate_moves()");
|
||||||
|
|
||||||
Bitboard bb = pos.pieces(Us, Pt);
|
Bitboard bb = piecesToMove & pos.pieces(Pt);
|
||||||
|
|
||||||
while (bb) {
|
while (bb) {
|
||||||
Square from = pop_lsb(&bb);
|
Square from = pop_lsb(&bb);
|
||||||
|
|
||||||
if (Checks)
|
if (Checks && (Pt == BISHOP || Pt == ROOK || Pt == QUEEN)
|
||||||
{
|
&& !(attacks_bb<Pt>(from) & target & pos.check_squares(Pt)))
|
||||||
if ( (Pt == BISHOP || Pt == ROOK || Pt == QUEEN)
|
continue;
|
||||||
&& !(attacks_bb<Pt>(from) & target & pos.check_squares(Pt)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (pos.blockers_for_king(~Us) & from)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bitboard b = attacks_bb<Pt>(from, pos.pieces()) & target;
|
Bitboard b = attacks_bb<Pt>(from, pos.pieces()) & target;
|
||||||
|
|
||||||
@@ -211,7 +205,10 @@ namespace {
|
|||||||
template<Color Us, GenType Type>
|
template<Color Us, GenType Type>
|
||||||
ExtMove* generate_all(const Position& pos, ExtMove* moveList) {
|
ExtMove* generate_all(const Position& pos, ExtMove* moveList) {
|
||||||
constexpr bool Checks = Type == QUIET_CHECKS; // Reduce template instantations
|
constexpr bool Checks = Type == QUIET_CHECKS; // Reduce template instantations
|
||||||
Bitboard target;
|
Bitboard target, piecesToMove = pos.pieces(Us);
|
||||||
|
|
||||||
|
if(Type == QUIET_CHECKS)
|
||||||
|
piecesToMove &= ~pos.blockers_for_king(~Us);
|
||||||
|
|
||||||
switch (Type)
|
switch (Type)
|
||||||
{
|
{
|
||||||
@@ -236,10 +233,10 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
moveList = generate_pawn_moves<Us, Type>(pos, moveList, target);
|
moveList = generate_pawn_moves<Us, Type>(pos, moveList, target);
|
||||||
moveList = generate_moves<Us, KNIGHT, Checks>(pos, moveList, target);
|
moveList = generate_moves<KNIGHT, Checks>(pos, moveList, piecesToMove, target);
|
||||||
moveList = generate_moves<Us, BISHOP, Checks>(pos, moveList, target);
|
moveList = generate_moves<BISHOP, Checks>(pos, moveList, piecesToMove, target);
|
||||||
moveList = generate_moves<Us, ROOK, Checks>(pos, moveList, target);
|
moveList = generate_moves< ROOK, Checks>(pos, moveList, piecesToMove, target);
|
||||||
moveList = generate_moves<Us, QUEEN, Checks>(pos, moveList, target);
|
moveList = generate_moves< QUEEN, Checks>(pos, moveList, piecesToMove, target);
|
||||||
|
|
||||||
if (Type != QUIET_CHECKS && Type != EVASIONS)
|
if (Type != QUIET_CHECKS && Type != EVASIONS)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user