bug or not

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

bug or not

Post by xr_a_y »

Reading Stockfish KPK code today, I found this

Code: Select all

 // Immediate win if a pawn can be promoted without getting captured
    else if (   us == WHITE
             && rank_of(psq) == RANK_7
             && ksq[us] != psq + NORTH
             && (    distance(ksq[~us], psq + NORTH) > 1
                 || (PseudoAttacks[KING][ksq[us]] & (psq + NORTH))))
        result = WIN;
where a Bitboard PseudoAttacks[][] is used (&) with a Square psq. Isn't this a bug ?
RubiChess
Posts: 584
Joined: Fri Mar 30, 2018 7:20 am
Full name: Andreas Matthies

Re: bug or not

Post by RubiChess »

SF code uses overloading operators in several places and this is one of them:

...
inline Bitboard operator&( Bitboard b, Square s) { return b & square_bb(s); }
---

Andreas
Last edited by RubiChess on Sat May 25, 2019 6:56 pm, edited 1 time in total.
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: bug or not

Post by xr_a_y »

RubiChess wrote: Sat May 25, 2019 6:54 pm SF code uses overloading operators in several places. I guess this is one of them.

Andreas
Thanks ! this is pretty :wink:

Code: Select all

inline Bitboard  operator&( Bitboard  b, Square s) { return b &  square_bb(s); }