Srdja Matovic
Joined: 10 Mar 2010 Posts: 310 Location: Hamburg - Germany
|
Post subject: Another Sliding Piece Move Generator -> BlockerTable Look Posted: Thu Jun 14, 2012 5:40 pm |
|
|
i am sure someone else tested this before....and my first implementation is slower than magic bitboards...anyway..
The Idea is to compute for every piece and all 8 directions the possible sliding-blockers and check this table against an precomputed AttackTable.
Here some pseudocode:
| Code: |
BlockerTable[9*64] // precomputed sliding-blockers
DirectionTable[4096] // from-to direction table
AttackTables[2*7*64] // precomputed attack tables
bbBlockersDirection[9] // BitBoards for dummy and 8 direction-BlockedMap
// *** Move Generator ***
// create blocked map
for every piece do {
pos = getPiecePos();
bbBlockersDirection[1] |= BlockerTable[1*64+pos];
bbBlockersDirection[2] |= BlockerTable[2*64+pos];
bbBlockersDirection[3] |= BlockerTable[3*64+pos];
bbBlockersDirection[4] |= BlockerTable[4*64+pos];
bbBlockersDirection[5] |= BlockerTable[5*64+pos];
bbBlockersDirection[6] |= BlockerTable[6*64+pos];
bbBlockersDirection[7] |= BlockerTable[7*64+pos];
bbBlockersDirection[8] |= BlockerTable[8*64+pos];
}
// create moves
for every own piece do {
from = getPiecePos();
piece = getPieceType();
// Get Pseudo-Legal Attacks
bbTemp = AttackTables[(som*7*64)+(piece*64)+from];
// TODO: pawn handling
while( bbTemp )
to = pop_1st_bit(bbTemp);
// Legality Attack Test, Test if slider is blocked
if ( IsSlider?(piece) && ( SetMaskBB[to] & bbBlockersDirection[DirectionTables[from*64+to]] ) )
continue;
// make and store move
}
}
|
|
|