Author: Sune Fischer
Date: 02:30:20 08/16/02
Go up one level in this thread
>i think your function don't considers the odd/even change between the ranks. >Square 0(A1) is black, 1(B1) is white... 7(H1)-is white >Square 8(A2) is white!... You are right, the observation was wrong. >// return: 0 = white square, 1 = black square >int colorOfsquare (int sq) { > return (sq^(sq>>3))&1;} > >bool sameSquareColor(int sq1, int sq2) { > return colorOfsquare(sq1) == colorOfsquare(sq2);} > >or > >bool sameSquareColor(int sq1, int sq2) { > return ((sq1^sq2^((sq1^sq2)>>3))&1) == 0;} > >Gerd If that works, then I think the computational complexity is still low enough to be faster than a table lookup, but guess that has to be tested. -S.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.