Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Position representation

Author: Sune Fischer

Date: 07:22:17 01/22/02

Go up one level in this thread


On January 21, 2002 at 22:16:47, Sean Mintz wrote:

>>but theres some even neater tricks you can use (which work for other board
>>representations too ...)
>>
>>go through the faile/sjeng source for the code. basically you have 2 special
>>arrays and one variable: pieces[32] and squares[128 (or however many squares in
>>your board)] and num_pieces. if filled correctly you'll only have to loop
>>num_pieces times. whenever a capture occurs (if you update these) you'll loop
>>less and less which should help speedup even more!
>
>heres how i loop now:
>
>int i,
>    j;
>
>for (i=1; i<=board->num_pieces; i++) {
>        j = board->pieces[i];
>
>        if ((j == -1) || (board->color[j] != board->wtm)) {
>                continue;
>        }
>
>        /* ... do whatever you want here */
>}
>
>as you can see, my loop is only as long as num_pieces. so if theres 5 pieces
>left you can imagine how fast it is :)


How do you test for checks?

-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.