Author: rasjid chan
Date: 03:39:41 04/10/04
Go up one level in this thread
On April 10, 2004 at 04:48:18, Daniel Shawul wrote:
>On April 09, 2004 at 02:30:36, rasjid chan wrote:
>Hi
>
> The AllPieces bitboard was what is left when i flipped from bitboards
> to 0x88. I thought it would help me in checking if a piece can slide between
> two squares. But it didn't. Doing while loops is as fast as the bitboard
>method on my pc. What i am saying is it may be good for a full Bitboard
>programme, but i am not sure if it helps for others.
I cannot understand when others seem to to say we can do completely
w/o bitboard. I only know simple bitboard and intuitive 0x88.
say :-
bool rook_attack(x, y){
if (aRay[128 + x - y] & aROOK){//test rook style
// call memory BAD ???
s= step[128 + x - y];// call memory BAD TWO)???
while{
;etc...
}
}
}
my rstyle_attack(x, y) has no array lookup and only bitwise
operation using your allbits all within registers.
IT MAY STILL BE SLOWER THEN 0x88 as I DONT TEST.
Do you say in this case ox88 still faster.
Do we ever need bool rook_attack(x, y) in chess programming in
the first place. Do you?
Another suggested place is
>to use them for pawn evaluation. This one i didn't try but i don't think it
>would do me anything good.what i am doing now is just loop through the pawns
>before i started eval of pawns [like tscp does] and fill my data. Since i use
>pawn hashes this is done rarely.
>
>best
>daniel
I am doubtful presently I can get a better way for this than that
of TSCP using least_advance_pawn[2][10]. Again intuitively IT IS THE
BEST. How much juice can you squeeze out of an orange by squeezing harder.
Rasjid
>
>
>>
>>
>>I have a set of simple macros for bitboard operations and they are meant for
>>those with a new chess program and like to implement fast complete
>>attacks by bishops and rooks. It is basically just three #define and all sliding
>>attacks would then be available for use in evaluations and move ordering. Of
>>course it is only when we don't yet count instruction cycles,
>>but then after things are moving we could EASILY upgrade to
>>rotated bitboards.
>>
>>The only requirement is that the "all" bits must be available. Most chess
>>programmers sooner or later will have to use some bitboard operations as
>>there seem no escape for the sliding pieces and it is usually necessary to
>>incrementally update the "all" bits after makemove()and unmake().
>>
>>These bitboard operations just make use of simple direct intuitive
>>operations.If we have a single bit x, then x - 1 divides the board into
>>upper half and lower half and add to it some bitwise operations which
>>everyone say is fast. The only memory access is U64 diagonal[2][15]
>>and it is much better than U64 attack[64][64].
>>For those not using 0x88, they just need some simple editing.
>>
>>If anyone has something faster or can make them faster, please post.
>>
>>Best Regards
>>Rasjid
>>
>>
>>typedef unsigned _int64 U64
>>
>>#define GetFile64(sq) ((sq) & 7)
>>#define GetRank64(sq) ((sq) >> 3)
>>#define iGetFile(sq88) ((sq88) & 7)
>>#define iGetRank(sq88) ((sq88) >> 4)
>>#define sq88Bit(sq88) ((U64)1 << (((sq88) + ((sq88) & 7)) >> 1))
>>#define sq64Bit(sq64) (((U64)1) << (sq64))
>>#define sq88RankBits(sq88) ((U64)0xff << ((sq88) >> 1 & 0370))
>>#define sq88FileBits(sq88) ((U64) 0x0101010101010101 << ((sq88) & 7))
>>
>>//*** global variables
>>U64 all, diagonal[2][15];
>>
>>
>>//*** Start - bitboard attack operations for sliding pieces
>>
>>/*
>> This test that the in-between arc (x, y) is clear of any bits.
>> path is the complete bit path along x, y across the board
>> */
>>
>>#define brq_path_clear(x, y, path)
>> ((x) <= (y)
>> ? ((x) == (y) || isqBit(y) - 1 & ~(isqBit(x) - 1 | isqBit(x))
>> & (path) & all ? 0 : 1)
>> : (isqBit(x) - 1 & ~(isqBit(y) - 1 | isqBit(y))
>> & (path) & all ? 0 : 1))
>>
>>/*
>> given any two sq88 x, y , this test if they attack along
>> diagonals.
>> */
>>
>>#define bstyle_attack(x, y)
>> (iGetRank(x) + iGetFile(x) == iGetRank(y) + iGetFile(y)
>> ? (brq_path_clear(x, y, diagonal[1][iGetRank(x)
>> + iGetFile(x)]) ? 1 : 0)
>> : (iGetRank(x) - iGetFile(x) == iGetRank(y) - iGetFile(y)
>> ? (brq_path_clear(x, y, diagonal[0][7 + iGetRank(x) - iGetFile(x)])
>> ? 1 : 0) : 0))
>>
>>/*
>> given any two sq88 x, y , this test if they attack along
>> rank or file.
>> */
>>
>>#define rstyle_attack(x, y)
>> (iGetRank(x) == iGetRank(y)
>> ? (brq_path_clear(x, y, isqRankBits(x)) ? 1 : 0)
>> : (iGetFile(x) == iGetFile(y)
>> ? (brq_path_clear(x, y, isqFileBits(x)) ? 1 : 0) : 0))
>>
>>
>>//*** End - bitboard attack operations for sliding pieces
>>
>>
>> void pre_calculate_diagonal(){
>> int i, j, l;
>> //get diagonal[2][15]
>>
>>
>> memset(diagonal, 0, sizeof(diagonal));
>> //LR down == [0][7 + r - f]
>> //RL down == [1][r + f]
>>
>> i = 0;
>> while(!(i & 0x88)){
>> l = iGetRank(i) - iGetFile(i);
>> assert(7 + l >= 0 && 7 + l < 15);
>> for (j = i; !(j & 0x88); j += 17){
>> diagonal[0][7 + iGetRank(j) - iGetFile(j)] |= isqBit(j);
>> assert(l == iGetRank(j) - iGetFile(j));
>> }
>>
>> l = iGetRank(i) + iGetFile(i);
>> assert(l >= 0 && l < 15);
>> for (j = i; !(j & 0x88); j += 15){
>> diagonal[1][iGetRank(j) + iGetFile(j)] |= isqBit(j);
>> assert(l == iGetRank(j) + iGetFile(j));
>> }
>> ++i;
>> }
>>
>> i = 16;
>> while(!(i & 0x88)){
>> l = iGetRank(i) - iGetFile(i);
>> assert(7 + l >= 0 && 7 + l < 15);
>> for (j = i; !(j & 0x88); j += 17){
>> diagonal[0][7 + iGetRank(j) - iGetFile(j)] |= isqBit(j);
>> assert(l == iGetRank(j) - iGetFile(j));
>> }
>> i += 16;
>> }
>>
>> i = 23;
>> while(!(i & 0x88)){
>> l = iGetRank(i) + iGetFile(i);
>> assert(l >= 0 && l < 15);
>> for (j = i; !(j & 0x88); j += 15){
>> diagonal[1][iGetRank(j) + iGetFile(j)] |= isqBit(j);
>> assert(l == iGetRank(j) + iGetFile(j));
>> }
>> i += 16;
>> }
>> }
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.