I wonder what is the reason that Crafty is using this word
in macros like SetMask or ClearMask or in many other arrays like rank_mask
It seems to me that this word is not succesful as a significant name because nothing is hidden and it is clearly simply having the information in BitBoard
I think that rankBB or setBB or ClearBB are shorter names that are more significant names and the reader can understand from the BB that it is a BitBoard.
The mask word in variables of chess program
Moderators: hgm, Rebel, chrisw
-
- Posts: 10281
- Joined: Thu Mar 09, 2006 12:37 am
- Location: Tel-Aviv Israel
-
- Posts: 838
- Joined: Thu Jul 05, 2007 5:03 pm
- Location: British Columbia, Canada
Re: The mask word in variables of chess program
Shorter isn't necessarily better. "Mask" is a meaningful word to programmers too. It all comes down to individual taste, I guess.
-
- Posts: 10281
- Joined: Thu Mar 09, 2006 12:37 am
- Location: Tel-Aviv Israel
Re: The mask word in variables of chess program
I agree that shorter is not always better but shorter name is an advantagewgarvin wrote:Shorter isn't necessarily better. "Mask" is a meaningful word to programmers too. It all comes down to individual taste, I guess.
if the other factors are the same and if we ignore length I do not see how the word mask is better.
I do not see why mask is more meanigful than BB
BB at least says that it is a bitboard.
The word mask does not mean that it is a bitboard and I guess somebody who writes a 32 bit program can also use setmask=(1<<i) for 0<=i<32
Again also in this case I think that setmask is not a good name and it is better to use power2
Uri
-
- Posts: 892
- Joined: Sun Nov 19, 2006 9:16 pm
- Location: Russia
Re: The mask word in variables of chess program
I disagree. Word "bitboard" have very little extra meaning except it is exact 64-bit number (similar to ugly Hungarian notation). I have seen many programs misleadingly used type "bitboard" for their Zobrist keys...
Term "mask" at least assumes that it is a constant predefined value used to calculate some actual value.
Term "mask" at least assumes that it is a constant predefined value used to calculate some actual value.
Last edited by Aleks Peshkov on Sat Mar 22, 2008 11:19 pm, edited 1 time in total.
-
- Posts: 838
- Joined: Thu Jul 05, 2007 5:03 pm
- Location: British Columbia, Canada
Re: The mask word in variables of chess program
Uri Blass wrote:I agree that shorter is not always better but shorter name is an advantagewgarvin wrote:Shorter isn't necessarily better. "Mask" is a meaningful word to programmers too. It all comes down to individual taste, I guess.
if the other factors are the same and if we ignore length I do not see how the word mask is better.
I do not see why mask is more meanigful than BB
BB at least says that it is a bitboard.
The word mask does not mean that it is a bitboard and I guess somebody who writes a 32 bit program can also use setmask=(1<<i) for 0<=i<32
Again also in this case I think that setmask is not a good name and it is better to use power2
Uri
Like I said, this is a matter of individual taste. I don't think I would use names like setBB or power2 in a chess engine, myself (not to my taste). However, I did have tables with names like kk1806 and pseudoD2, which were meaningful to me but might have been not as clear to anyone else reading my code.
Let me turn your question around: since Dr. Hyatt has been working on Crafty for more than a decade, and he's probably had the names like SetMask in there for a very long time, and he is probably very used to them and so is anybody who has been looking at crafty over the years... why should he change them? I think it would not make sense to make such an arbitrary change without a much stronger justification than the ones you've given.
-
- Posts: 10281
- Joined: Thu Mar 09, 2006 12:37 am
- Location: Tel-Aviv Israel
Re: The mask word in variables of chess program
It seems obvious for me that setBB or FileBB is translation of i to BitBoard.Aleks Peshkov wrote:I disagree. Word "bitboard" have very little extra meaning except it is exact 64-bit number (similar to ugly Hungarian notation). I have seen many programs misleadingly used type "bitboard" for their Zobrist keys...
Term "mask" at least assumes that it is a constant predefined value used to calculate some actual value.
It is clear that i itself cannot be a bitboard because computers have not enough memory for 2^64 elements in an array so the only logical thinking is translation of set that include i to BitBoard or translation of File number i to BitBoard.
Uri
-
- Posts: 3196
- Joined: Fri May 26, 2006 3:00 am
- Location: WY, USA
- Full name: Michael Sherwin
Re: The mask word in variables of chess program
A mask hides things. In chess programming rankMask hides all but the rank that is in question. It is an English language description of a variable rather than a non language description such as rankBB. Dr. Hyatt is also a professor at a university where computer science is taught. So, rankMask would be more meaningfull than rankBB in that setting.Uri Blass wrote:I wonder what is the reason that Crafty is using this word
in macros like SetMask or ClearMask or in many other arrays like rank_mask
It seems to me that this word is not succesful as a significant name because nothing is hidden and it is clearly simply having the information in BitBoard
I think that rankBB or setBB or ClearBB are shorter names that are more significant names and the reader can understand from the BB that it is a BitBoard.
If you are on a sidewalk and the covid goes beep beep
Just step aside or you might have a bit of heat
Covid covid runs through the town all day
Can the people ever change their ways
Sherwin the covid's after you
Sherwin if it catches you you're through
Just step aside or you might have a bit of heat
Covid covid runs through the town all day
Can the people ever change their ways
Sherwin the covid's after you
Sherwin if it catches you you're through
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: The mask word in variables of chess program
It tells me what the thing does. If It is a "mask" then it is used to either mask off specific squares (turn them to zero) or else it masks all squares but the given set to keep them...Uri Blass wrote:I wonder what is the reason that Crafty is using this word
in macros like SetMask or ClearMask or in many other arrays like rank_mask
It seems to me that this word is not succesful as a significant name because nothing is hidden and it is clearly simply having the information in BitBoard
I think that rankBB or setBB or ClearBB are shorter names that are more significant names and the reader can understand from the BB that it is a BitBoard.
If you don't like the term, use what you want. I consider this different than other bitboardy things I do, and wanted variable names that would cause me to remember what I am reading...
BTW, part of this comes from my Cray background, where there was a "mask" hardware instruction, used to create a word with the left N, or the right N bits set to one. I kept that terminology for quite a while (set_mask[n] is one example) where it is not quite as appropriate as it could be, but it translated to one instruction on the cray where I could say "I want a 64 bit value with just bit 1 set, or with the rightmost N bits set, or the leftmost N bits set..."
Last edited by bob on Sun Mar 23, 2008 1:56 am, edited 1 time in total.
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: The mask word in variables of chess program
Michael Sherwin wrote:A mask hides things. In chess programming rankMask hides all but the rank that is in question. It is an English language description of a variable rather than a non language description such as rankBB. Dr. Hyatt is also a professor at a university where computer science is taught. So, rankMask would be more meaningfull than rankBB in that setting.Uri Blass wrote:I wonder what is the reason that Crafty is using this word
in macros like SetMask or ClearMask or in many other arrays like rank_mask
It seems to me that this word is not succesful as a significant name because nothing is hidden and it is clearly simply having the information in BitBoard
I think that rankBB or setBB or ClearBB are shorter names that are more significant names and the reader can understand from the BB that it is a BitBoard.
while I agree with you, I would also add that Uri has a point for some variables in Crafty. "set_mask" is probably poorly named since it isn't always used as a "mask" at all (only one bit is set in any particular element of that array). But for many other cases, "mask" seems to be the right term (at least among the programming things I have been involved in in the past) since they are usually used to exclude certain squares on only include certain squares, as a set...
-
- Posts: 10281
- Joined: Thu Mar 09, 2006 12:37 am
- Location: Tel-Aviv Israel
Re: The mask word in variables of chess program
Michael Sherwin wrote:A mask hides things. In chess programming rankMask hides all but the rank that is in question. It is an English language description of a variable rather than a non language description such as rankBB. Dr. Hyatt is also a professor at a university where computer science is taught. So, rankMask would be more meaningfull than rankBB in that setting.Uri Blass wrote:I wonder what is the reason that Crafty is using this word
in macros like SetMask or ClearMask or in many other arrays like rank_mask
It seems to me that this word is not succesful as a significant name because nothing is hidden and it is clearly simply having the information in BitBoard
I think that rankBB or setBB or ClearBB are shorter names that are more significant names and the reader can understand from the BB that it is a BitBoard.
In this case I guess that NotrankBB[] is also better than rankBB[]
I thought about the case that rankBB is a BitBoard that have 1 for the rank and 0 for other squares.
I did not learn most of the code of Crafty and the time that I use to examine other sources is mainly used for strelka's code.
I replace the names of the variables in strelka by more significant names in order to have code that is easier to understand for me and I think that most of the mask in strelka that is probably inspired by the setmask in Crafty is misleading.
Uri