I do not like magic numbers that are in strelka like
0x0000FEFEFEFEFE00 and I replaced part of them by constants.
I wonder what is going to be good name for this bitboard that is about squares when pawns can capture to the left side without promotion.
This is basically ranks 2-6 and files b-h
A name like "white_pawn_can_capture_left_without_promotion" seems too long to my eye and some short name may be confusing about the meaning.
An alternative name is "NotfileANotrank178"
I wonder what you do in your program because I find that with bitboards you need big names to describe the meaning of variables.
You can claim that it is good because you catch a lot of information in one variable but the problem is what names to give to the variable.
Uri
choosing names to constant numbers in chess programs
Moderator: Ras
-
- Posts: 10792
- Joined: Thu Mar 09, 2006 12:37 am
- Location: Tel-Aviv Israel
-
- Posts: 1808
- Joined: Wed Mar 08, 2006 9:19 pm
- Location: Oslo, Norway
Re: choosing names to constant numbers in chess programs
In Glaurung, it would be:Uri Blass wrote:I do not like magic numbers that are in strelka like
0x0000FEFEFEFEFE00 and I replaced part of them by constants.
I wonder what is going to be good name for this bitboard that is about squares when pawns can capture to the left side without promotion.
This is basically ranks 2-6 and files b-h
A name like "white_pawn_can_capture_left_without_promotion" seems too long to my eye and some short name may be confusing about the meaning.
Code: Select all
~Rank1BB & ~Rank8BB & ~FileABB
Not in my experience. The longest name in my bitboard code is the array ThisAndNeighboringFilesBB[], which is indexed by a file, and gives a bitboard representing all squares in the given file and its neighboring files.I wonder what you do in your program because I find that with bitboards you need big names to describe the meaning of variables.
Tord
-
- Posts: 10792
- Joined: Thu Mar 09, 2006 12:37 am
- Location: Tel-Aviv Israel
Re: choosing names to constant numbers in chess programs
Thanks for your advice.Tord Romstad wrote:In Glaurung, it would be:Uri Blass wrote:I do not like magic numbers that are in strelka like
0x0000FEFEFEFEFE00 and I replaced part of them by constants.
I wonder what is going to be good name for this bitboard that is about squares when pawns can capture to the left side without promotion.
This is basically ranks 2-6 and files b-h
A name like "white_pawn_can_capture_left_without_promotion" seems too long to my eye and some short name may be confusing about the meaning.This looks simple enough to me. Because Rank1BB, Rank8BB and FileABB are constants, the compiler will generate a single constant from this expression.Code: Select all
~Rank1BB & ~Rank8BB & ~FileABB
Not in my experience. The longest name in my bitboard code is the array ThisAndNeighboringFilesBB[], which is indexed by a file, and gives a bitboard representing all squares in the given file and its neighboring files.I wonder what you do in your program because I find that with bitboards you need big names to describe the meaning of variables.
Tord
I can easily think of cases when longer names than your name are needed when the names are not related to bitboards.
For example you can use the following array for penalty for passed pawns that are blocked by an opponent piece.
PassedPawnPenaltyBlockedEnemy
Uri
-
- Posts: 10792
- Joined: Thu Mar 09, 2006 12:37 am
- Location: Tel-Aviv Israel
Re: choosing names to constant numbers in chess programs
Note that in this example you need also ~Rank7BB and I think that it may be better to have also one Rank178 constant for that purpose that seems clear enough for me.Tord Romstad wrote:In Glaurung, it would be:Uri Blass wrote:I do not like magic numbers that are in strelka like
0x0000FEFEFEFEFE00 and I replaced part of them by constants.
I wonder what is going to be good name for this bitboard that is about squares when pawns can capture to the left side without promotion.
This is basically ranks 2-6 and files b-h
A name like "white_pawn_can_capture_left_without_promotion" seems too long to my eye and some short name may be confusing about the meaning.This looks simple enough to me. Because Rank1BB, Rank8BB and FileABB are constants, the compiler will generate a single constant from this expression.Code: Select all
~Rank1BB & ~Rank8BB & ~FileABB
Tord
Uri