Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: It seems to me more logical instead of firstone and lastone to use

Author: Robert Hyatt

Date: 07:34:51 01/26/03

Go up one level in this thread


On January 26, 2003 at 07:35:32, Uri Blass wrote:

>other functions that give 63-firstone and 63-lastone.
>
>I looked at the code of crafty to see crafty's implementation of firstone and I
>find that firstone simply count the zeros behind the first 1.

That is correct.   I originally designed this for the Cray, and on the Cray,
just like on the power pc, there is a "count leading zeros" instruction.  It
makes sense to make the MSB bit 0 in this case.  On the PC, it is less efficient
and I might well change it one day.



>
>It is logical by definition because we can say that we find the place of the
>first one but chess programs do not need to find the place of the first 1 but to
>find the meaning of the first 1.
>
>suppose that 259 is a bitboard and we want to evaluate the squares that are
>relevant for that bitboard
>
>259=1+2+256=2^0+2^1+2^8
>
>0 intuitivily is a1
>1 is intuitively b1
>8 is intuitivily a2 so we want to evaluate these squares.

You can do that no matter whether bit 0 is the leftmost bit or the rightmost
bit.  The "meaning" of a bit is independent of its location.  The location is
only an issue for the architectural implementation you use.  The "meaning" is
inherent in the program and is independent of the location of the bit.  Ie you
could design an engine with bit 15 = a1, bit 4 = a2, etc.  No good reason to
do that, but it would work.

>
>in other words we want to get the numbers 0,1,8 from 259
>
>if we use firstone(259) we get 55 because there are 55 0's before 259
>
>55 is not one of these numbers and we need to do 63- in order to get the
>relevant numbers when we use firstone.

that is only because you are logically associating the bit number with a
different square than I do.

>
>it is more logical to do
>
>antifirstone(259)=8 so we can avoid the 63-(antifirstone is not a good name but
>I did not find a good name at this moment)



No it isn't.  All you need to do is change your "logical representation" so
that bit 0 = a1, or bit 63 = a1, depending on which you like best.  There is
_no_ inherent advantage in either, other than to choose the numbering scheme
that is most efficient on the hardware you are going to use.



>
>You can claim that I may define the bitboard in another way when 1 means h8 but
>I see no logical reason to do it.

And there is no logical reason not to do it either.  when you see an array

xxx[5][10] do you see an array with 5 rows and 10 columns?  Not to the
hardware.  It could be used as 5 columns and 10 rows and the hardware would
be just as happy.  Just so your "logical implementation" uses the array in
that way, it would work just fine.

>
>I wonder if there is a special reason that I do not understand to do Firstone in
>the way that Bob does it.


The cray and the powerpc, the original platform it was designed for.



>
>The only reason that I can find to start with the last rank is the definition of
>FEN that for some reason that I fail to understand starts from the last rank and
>not from the first rank but even in FEN they do not start from the last file.
>
>Uri


Fen starts from the last rank because, by standard, chess boards are displayed
with white on the bottom.  It is more natural to read left to right, top to
bottom, which means a8-h8, a7-h7, ..., a1-h1

It was done for simplicity and nothing else.



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.