rajeshverma423 wrote:Code :
http://www.koders.com/java/fid2A9848F82 ... SideEffectPosition : e4e5 Bc4
What will be the value used of attack : public static int calcRookControl(Position pos, int sqSrc, byte[] attack) {
return calcSlideControl(pos, sqSrc, attack, true);
}
Which is board index?
The routines are apparently called for each bishop and rook, so after e4e5 Bc4 with {c1,c4},{c8, f8} and {a1,h1}, {a8,h8}, that is calcSlideControl is called 8 times with the squares where the pieces actually reside on the board. The total mobility or control value is then the sum of white pieces minus sum of black pieces.
calcSlideControl somehow aggregates a kind of mobility / x-ray mobility or control measure per sliding piece. Board index of a rook or bishop is sqSrc, the weights or boni of squares are passed via attack[]. It loops over all four ray directions and all destination squares per ray to add a bonus[sqDst], starting from sqSrc + delta[dir]. It stops counting per ray after a pawn blocks the destination, but continues otherwise. Once a blocker is a piece not sharing the same move direction, weights of farther squares are divided by two (direct = false). This approach assumes pieces are mobile but pawns are not, and seems to overestimate x-ray attacks through multiple own or opponent pieces, for instance with a full back rank from the initial position, the a1 rook still indirectly controls h1!?