50-move counter update

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
hgm
Posts: 28356
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: 50-move counter update

Post by hgm »

Gerd Isenberg wrote:Your code is somehow hard to read at the first glance. Do you mean that?

Code: Select all

revMovesAndCastlRights +=  256; 
revMovesAndCastlRights &=  (int) ( (char) (spoiler[piece] + 64) & spoiler[victim] );
One other remark:

I did not include the increment of the move counter in my first code snippet because it is best done in another place (outside the move loop):

Code: Select all

Search(int revMovesAndCastlRights)
{
    revMovesAndCastlRights += 256;
    for(ALL_MOVES)
    {
        Make();
        Search(revMovesAndCastlRights & ( (char) (spoiler[piece]+64)) & spoiler[victim]);
        UnMake();
    }
}