I noticed that in my 32 bit engine, Kindergarten Bitboard Approach is a little bit faster compared to that of Olithink bitboard method. It is more elegant and uses less memory. But what I like about the Olithink method is that it has X-ray attacks and it makes my routines for pinned and discovered pieces faster.
Is there a way to modify Kindergarten Bitboard Approach to support X-ray attacks just like the Olithink bitboard method?
Kindergarten Bitboard Approach by Gerd Isenberg
Moderators: hgm, Rebel, chrisw
-
- Posts: 803
- Joined: Mon Jul 17, 2006 5:53 am
- Full name: Edsel Apostol
-
- Posts: 2250
- Joined: Wed Mar 08, 2006 8:47 pm
- Location: Hattingen, Germany
Re: Kindergarten Bitboard Approach by Gerd Isenberg
Hi Edsel,Edsel Apostol wrote:I noticed that in my 32 bit engine, Kindergarten Bitboard Approach is a little bit faster compared to that of Olithink bitboard method. It is more elegant and uses less memory. But what I like about the Olithink method is that it has X-ray attacks and it makes my routines for pinned and discovered pieces faster.
Is there a way to modify Kindergarten Bitboard Approach to support X-ray attacks just like the Olithink bitboard method?
yes, see X-ray Attacks, chapter X-rays with one Lookup.
I is only a matter to initialize the lookup tables accordantly.
Gerd
-
- Posts: 803
- Joined: Mon Jul 17, 2006 5:53 am
- Full name: Edsel Apostol
Re: Kindergarten Bitboard Approach by Gerd Isenberg
Thanks Gerd.
CPW is a great resource indeed. I should have browse it first before asking here.
By the way, I found this code in one of your posts in the links:
Is your code above faster than my implementation below?
rookAttacksBBX and bishopAttacksBBX are xray attacks using Olithink method. That's why I'm asking if there's an equivalent routine for that in Kindergarten Bitboard method as I want my engine to use less memory and have an elegant code.
CPW is a great resource indeed. I should have browse it first before asking here.
By the way, I found this code in one of your posts in the links:
Code: Select all
rookWise = rookAttacks(occ, kiSq);
potPinned = rookWise & ownPieces;
xrays = rookWise ^ rookAttacks(occ ^ potPinned, kiSq);
pinners = xrays & oppoRookOrQueen;
pinned = 0;
while ( pinners )
{
pinnerSq = bitScanForward(pinners);
pinned |= potPinned & obstructed[pinnerSq][kiSq]);
pinners &= pinners - 1;
}
... same for bishops/queens
Code: Select all
u64 pinnedPieces(const position_t *pos, u32 c) {
u64 b, pin, pinners; int t, ksq;
pin = 0ULL;
ksq = pos->kpos[c];
pinners = pos->color[c^1] & (pos->queens|pos->rooks);
if(pinners){
b = rookAttacksBBX(ksq, pos->occupied) & pinners;
while (b) {
t = popFirstBit(&b);
pin |= InBetween[t][ksq] & pos->color[c];
}
}
pinners = pos->color[c^1] & (pos->queens|pos->bishops);
if(pinners){
b = bishopAttacksBBX(ksq, pos->occupied) & pinners;
while (b) {
t = popFirstBit(&b);
pin |= InBetween[t][ksq] & pos->color[c];
}
}
return pin;
}
Edsel Apostol
https://github.com/ed-apostol/InvictusChess
https://github.com/ed-apostol/InvictusChess
-
- Posts: 2250
- Joined: Wed Mar 08, 2006 8:47 pm
- Location: Hattingen, Germany
Re: Kindergarten Bitboard Approach by Gerd Isenberg
Hard to say - I neither use the one or the other, but fill algorithms with intersection of dir attacks of sliding pieces with opposite dir of king as slider. The mentioned routines can not been considered isolated, but together with surrounding code, and whether sub-expressions are reused or explicitly cached, also in the context of dicovered checks and whether kings are vulnerable to distant checks in eval and check move-generation etc ...Edsel Apostol wrote:Thanks Gerd.
CPW is a great resource indeed. I should have browse it first before asking here.
By the way, I found this code in one of your posts in the links:Is your code above faster than my implementation below?Code: Select all
rookWise = rookAttacks(occ, kiSq); potPinned = rookWise & ownPieces; xrays = rookWise ^ rookAttacks(occ ^ potPinned, kiSq); pinners = xrays & oppoRookOrQueen; pinned = 0; while ( pinners ) { pinnerSq = bitScanForward(pinners); pinned |= potPinned & obstructed[pinnerSq][kiSq]); pinners &= pinners - 1; } ... same for bishops/queens
rookAttacksBBX and bishopAttacksBBX are xray attacks using Olithink method. That's why I'm asking if there's an equivalent routine for that in Kindergarten Bitboard method as I want my engine to use less memory and have an elegant code.Code: Select all
u64 pinnedPieces(const position_t *pos, u32 c) { u64 b, pin, pinners; int t, ksq; pin = 0ULL; ksq = pos->kpos[c]; pinners = pos->color[c^1] & (pos->queens|pos->rooks); if(pinners){ b = rookAttacksBBX(ksq, pos->occupied) & pinners; while (b) { t = popFirstBit(&b); pin |= InBetween[t][ksq] & pos->color[c]; } } pinners = pos->color[c^1] & (pos->queens|pos->bishops); if(pinners){ b = bishopAttacksBBX(ksq, pos->occupied) & pinners; while (b) { t = popFirstBit(&b); pin |= InBetween[t][ksq] & pos->color[c]; } } return pin; }
As I already said, in your mentioned post, the X-ray lookup seems the faster precondition for
Code: Select all
opponentSlider -> anyPiece -> ownKing
Code: Select all
opponentSlider -> ownPiece -> ownKing