Right now I'm doing something like:
- Code: Select all
//Fillled attacks - initial place included
U64 Rfill(U64 pieces, U64 occ)
{
occ=~(occ&~pieces);
return fillUpOccluded(pieces,occ<<8)|fillDownOccluded(pieces,occ>>8)
|fillRightOccluded(pieces,occ>>1)|fillLeftOccluded(pieces,occ<<1);
}
U64 Bfill(U64 pieces, U64 occ)
{
occ=~(occ&~pieces);
return fillUpLeftOccluded(pieces,occ<<9)|fillDownRightOccluded(pieces,occ>>9)
|fillUpRightOccluded(pieces,occ<<7)|fillDownLeftOccluded(pieces,occ>>7);
}
U64 Qfill(U64 pieces, U64 occ)
{
occ=~(occ&~pieces);
return fillUpOccluded(pieces,occ<<8)|fillDownOccluded(pieces,occ>>8)
|fillRightOccluded(pieces,occ>>1)|fillLeftOccluded(pieces,occ<<1)
|fillUpLeftOccluded(pieces,occ<<9)|fillDownRightOccluded(pieces,occ>>9)
|fillUpRightOccluded(pieces,occ<<7)|fillDownLeftOccluded(pieces,occ>>7);
}
U64 Nfill(U64 pieces)
{
return
pieces |
//left 2 up 1
( (pieces<< 6) & C64(0x3F3F3F3F3F3F3F3F) ) |
//right 2 up 1
( (pieces<<10) & C64(0xFCFCFCFCFCFCFCFC) ) |
//left 1 up 2
( (pieces<<15) & C64(0x7F7F7F7F7F7F7F7F) ) |
//right 1 up 2
( (pieces<<17) & C64(0xFEFEFEFEFEFEFEFE) ) |
//left 2 down 1
( (pieces>> 6) & C64(0xFCFCFCFCFCFCFCFC) ) |
//right 2 down 1
( (pieces>>10) & C64(0x3F3F3F3F3F3F3F3F) ) |
//left 1 down 2
( (pieces>>15) & C64(0xFEFEFEFEFEFEFEFE) ) |
//right 1 down 2
( (pieces>>17) & C64(0x7F7F7F7F7F7F7F7F) ) ;
}
U64 Kfill(U64 pieces)
{
pieces |= (pieces << 8) | (pieces >> 8);
return ((pieces<<1)&0xFEFEFEFEFEFEFEFE) | ((pieces>>1)&0x7F7F7F7F7F7F7F7F);
}
where
- Code: Select all
U64 fillUpOccluded(U64 g, U64 p)
{
g |= p & (g << 8);
p &= (p << 8);
g |= p & (g << 16);
p &= (p << 16);
return g |= p & (g << 32);
}
U64 fillDownOccluded(U64 g, U64 p)
{
g |= p & (g >> 8);
p &= (p >> 8);
g |= p & (g >> 16);
p &= (p >> 16);
return g |= p & (g >> 32);
}
U64 fillLeftOccluded(U64 g, U64 p)
{
p &= C64(0xFEFEFEFEFEFEFEFE);
g |= p & (g << 1);
p &= (p << 1);
g |= p & (g << 2);
p &= (p << 2);
return g |= p & (g << 4);
}
U64 fillRightOccluded(U64 g, U64 p)
{
p &= C64(0x7F7F7F7F7F7F7F7F);
g |= p & (g >> 1);
p &= (p >> 1);
g |= p & (g >> 2);
p &= (p >> 2);
return g |= p & (g >> 4);
}
U64 fillUpLeftOccluded(U64 g, U64 p)
{
p &= C64(0xFEFEFEFEFEFEFEFE);
g |= p & (g << 9);
p &= (p << 9);
g |= p & (g << 18);
p &= (p << 18);
return g |= p & (g << 36);
}
U64 fillUpRightOccluded(U64 g, U64 p)
{
p &= C64(0x7F7F7F7F7F7F7F7F);
g |= p & (g << 7);
p &= (p << 7);
g |= p & (g << 14);
p &= (p << 14);
return g |= p & (g << 28);
}
U64 fillDownLeftOccluded(U64 g, U64 p)
{
p &= C64(0xFEFEFEFEFEFEFEFE);
g |= p & (g >> 7);
p &= (p >> 7);
g |= p & (g >> 14);
p &= (p >> 14);
return g |= p & (g >> 28);
}
U64 fillDownRightOccluded(U64 g, U64 p)
{
p &= C64(0x7F7F7F7F7F7F7F7F);
g |= p & (g >> 9);
p &= (p >> 9);
g |= p & (g >> 18);
p &= (p >> 18);
return g |= p & (g >> 36);
}
Is there a faster way to generate move bitboards for multiple pieces? (Espically for the slider pieces)