Author: Bas Hamstra
Date: 13:12:33 01/13/03
Go up one level in this thread
On January 13, 2003 at 10:06:19, Dieter Buerssner wrote:
>On January 13, 2003 at 09:01:55, Bas Hamstra wrote:
>
>>Sorted piecelist, yes, updated via make/unmake. The cost of this feature is
>>that I went from about 5M make/unmakes a second to 4M. The idea is to generate
>>captures at MVV/LVA order in the qsearch one at a time, in which case a sorted
>>piecelist is more or less needed. This, I hoped, would give an even higher
>>nps. With an unsorted piecelist, you would be forced to generate/sort all
>> captures. Your opinion?
>
>I can't know, really. But I see the idea. OTOH, selecting the best (in the
>sense of MVV/LVA order) move at qsearch time might not be to costy, either.
Wow, wait. Supposing victim is not in check, you have to loop to search for the
(say) queen. Not attacked. Loop for a rook...etc. Looks to me a sorted list is a
good idea here.
>When I sent my first reply, I did not recognize, that you sorted the piece
>list. In this case, I woul think, that having pawn outside the loop should be
>faster most of the time, because typically, you will get an early break in the
>loop.
>With clever defining of pieces, the extra branch (for the early break
>condition) would come at little cost.
>
>For example:
>
>#define pawn 1
>#define knight 2
>#define bishop 4
>#define rook 8
>#define queen 16
>#define king 32
>
>The color bit could be 64. Then test for non sweeping pieces would be as easy
>as
>
> if (piece & (knight|king|pawn))
>
>When you end your piece list with (say) 127, and have a "zero piece" at
>board[127], the loop could be something like
>
> int *piecelistp = piecelist[color];
>
> while (1)
> {
> from = *pieclistp++;
> piece = board[from] & 63; // piece must be signed, or a cast needed later
> if (piece-1 <= 0) // catches end of list and pawn
> return 0;
> if (pseudo_attack_table[127+to-from] & piece) //No shift needed anymore
> {
> /* if (piece & (knight|king)) return 1; */
> d = dir[127+to-from];
> do
> {
> from += d;
> if (from == to)
> return 1;
> }
> while (!board[from]);
> }
>
>Totally untested, just an idea. I hope no serious flaws in it.
It looks very tight. I noticed the few little shifts I did are really costly,
just eliminating the 1<<Type gives 20%, so I will probably try something like
this... Besides it also got me thinking about shifts in other (heavily
used)places. Replacing the Piecelist[x][y] with a pointer seems to give no
noticable improvement, neither does replacing for() with do-while(). For
Borland, that is.
Best regards,
Bas.
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.