sf see code , how does this work ?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

MahmoudUthman
Posts: 234
Joined: Sat Jan 17, 2015 11:54 pm

sf see code , how does this work ?

Post by MahmoudUthman »

current code on GitHub Position.cpp @Line:1054

Code: Select all

// Don't allow pinned pieces to attack pieces except the king as long all 
 // pinners are on their original square. 
       if (!(st->pinnersForKing[stm] & ~occupied)) 
           stmAttackers &= ~st->blockersForKing[stm]; 

&What are pinnersforking ?
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: sf see code , how does this work ?

Post by Sven »

MahmoudUthman wrote:current code on GitHub Position.cpp @Line:1054

Code: Select all

// Don't allow pinned pieces to attack pieces except the king as long all 
 // pinners are on their original square. 
       if (!(st->pinnersForKing[stm] & ~occupied)) 
           stmAttackers &= ~st->blockersForKing[stm]; 

&What are pinnersforking ?
This SEE implementation is quite sophisticated regarding its handling of x-ray attacks and pinned pieces. The code was already present in SF8. The "pinnersForKing" and "blockersForKing" bitboards are initialized in set_check_info() which is always called when a move is made and several information is updated incrementally. "blockersForKing" contains all pieces that are pinned to the king of given color, and "pinnersForKing" contains those pieces (sliders) that pin them. In the SEE code it is used to exclude pinned pieces from the set of attackers that have to be considered to calculate the SEE score. The "occupied" bitboard is updated by each call of min_attacker<PAWN>() within the SEE loop. The code snippet above says, if I understand it correctly: if there are pinners left that were not yet consumed (i.e. removed from "occupied" because they "captured") then remove all pinned pieces of that color from the attackers set.