mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00: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:
parent
c4d67d77c9
commit
4d30438400
2 changed files with 15 additions and 17 deletions
1
AUTHORS
1
AUTHORS
|
@ -33,6 +33,7 @@ Bill Henry (VoyagerOne)
|
|||
Bojun Guo (noobpwnftw, Nooby)
|
||||
braich
|
||||
Brian Sheppard (SapphireBrand, briansheppard-toast)
|
||||
Bruno de Melo Costa (BM123499)
|
||||
Bryan Cross (crossbr)
|
||||
candirufish
|
||||
Chess13234
|
||||
|
|
|
@ -175,25 +175,19 @@ namespace {
|
|||
}
|
||||
|
||||
|
||||
template<Color Us, PieceType Pt, bool Checks>
|
||||
ExtMove* generate_moves(const Position& pos, ExtMove* moveList, Bitboard target) {
|
||||
template<PieceType Pt, bool Checks>
|
||||
ExtMove* generate_moves(const Position& pos, ExtMove* moveList, Bitboard piecesToMove, Bitboard target) {
|
||||
|
||||
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) {
|
||||
Square from = pop_lsb(&bb);
|
||||
|
||||
if (Checks)
|
||||
{
|
||||
if ( (Pt == BISHOP || Pt == ROOK || Pt == QUEEN)
|
||||
&& !(attacks_bb<Pt>(from) & target & pos.check_squares(Pt)))
|
||||
continue;
|
||||
|
||||
if (pos.blockers_for_king(~Us) & from)
|
||||
continue;
|
||||
}
|
||||
if (Checks && (Pt == BISHOP || Pt == ROOK || Pt == QUEEN)
|
||||
&& !(attacks_bb<Pt>(from) & target & pos.check_squares(Pt)))
|
||||
continue;
|
||||
|
||||
Bitboard b = attacks_bb<Pt>(from, pos.pieces()) & target;
|
||||
|
||||
|
@ -211,7 +205,10 @@ namespace {
|
|||
template<Color Us, GenType Type>
|
||||
ExtMove* generate_all(const Position& pos, ExtMove* moveList) {
|
||||
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)
|
||||
{
|
||||
|
@ -236,10 +233,10 @@ namespace {
|
|||
}
|
||||
|
||||
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);
|
||||
moveList = generate_moves<KNIGHT, Checks>(pos, moveList, piecesToMove, target);
|
||||
moveList = generate_moves<BISHOP, Checks>(pos, moveList, piecesToMove, target);
|
||||
moveList = generate_moves< ROOK, Checks>(pos, moveList, piecesToMove, target);
|
||||
moveList = generate_moves< QUEEN, Checks>(pos, moveList, piecesToMove, target);
|
||||
|
||||
if (Type != QUIET_CHECKS && Type != EVASIONS)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue