The Super Piece

Discussion of chess software programming and technical issues.

Moderator: Ras

Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

The Super Piece

Post by Mike Sherwin »

I'm writing the is square attacked functions. On the CPW it mentions the Super Piece idea. I've rejected that idea in the past because in the start position it intersects with the other sides pieces every time. Though it seems reasonable for the endgame. Am I missing something about the Super Piece solution? Here is my code. Is it reasonable or is there something that I am not aware of?

Code: Select all

bool AtkByBlack(Thread* t, u64 sqs) {
  s32 sq;
  u64 bb, occ;

  occ = pieceSquareBits[WHITE] | pieceSquareBits[BLACK];

  do {
    sq = std::countr_zero(sqs);
    if (bob[sq] & (bQueens | bBishops)) {
      bb = 
        ray[std::countr_zero(ray[sq].rayNW & occ)].rayNW |
        ray[std::countr_zero(ray[sq].rayNE & occ)].rayNE |
        ray[63 - std::countl_zero(ray[sq].raySE & occ)].raySE |
        ray[63 - std::countl_zero(ray[sq].raySW & occ)].raySW ^
        bob[sq];
      if (bb & (bQueens | bBishops)) return true;
    }
    if (rob[sq] & (bQueens | bRooks)) {
      bb =
        ray[std::countr_zero(ray[sq].rayNN & occ)].rayNN |
        ray[std::countr_zero(ray[sq].rayEE & occ)].rayEE |
        ray[63 - std::countl_zero(ray[sq].raySS & occ)].raySS |
        ray[63 - std::countl_zero(ray[sq].rayWW & occ)].rayWW ^
        rob[sq];
      if (bb & (bQueens | bRooks)) return true;
    }
    if (knightMoves[sq] & bKnights) return true;
    if (wPawnCapts[sq] & bPawns) return true;
    if (kingMoves[sq] & kings[BLACK]) return true;
    sqs ^= 1ull << sq;
  } while (sqs);
  return false;
}