Author: Tim Foden
Date: 02:34:48 05/12/02
Go up one level in this thread
On May 12, 2002 at 02:53:12, Matthias Gemuh wrote:
>On May 12, 2002 at 00:23:07, Robert Hyatt wrote:
>
>>On May 11, 2002 at 05:48:17, Matthias Gemuh wrote:
>>
>>>
>>>Hi Experts,
>>>how much faster can I compute attacks when I rotate ? 5%? 20%? 50%?
>>>I don't understand rotation and hope the gain is 1% speed boost :-).
>>>Regards,
>>>Matthias.
>>
>>It is more than that. The main thing is that it eliminates the loop needed
>>to find where a particular diagonal, file or rank is blocked. Generating
>>the attacks on a particular "ray" becomes a simple table lookup...
>
>
>I don't loop. I use an idea from Crafty (blocking squares)
>
>if (((MovesAndAttacks->obstructed[k][j] & BitBoth) == 0) &&
> (MovesAndAttacks->SlidingMoves[bishop][k]&ChsPos->Mask[j]))
>
>tells me bishop on square k can move unhindered to square j.
>Is this too expensive ?
Let's see if I understand this. You have a bishop on square k, and you are
testing whether the bishop can be moved to square j?
How do you get the value for j?
Maybe an example of generating ALL the moves for the bishop would be more
beneficial.
A rotated bitboard implementation will do something like this (this is adapted
from the code in Green Light):
// first we generate the bitmap of all moves
int rank = Rank(from);
int file = File(from);
UINT8 diag1 = m_bitBoard.m_rows[bbDiag1 + 7 + rank - file];
UINT8 diag2 = m_bitBoard.m_rows[bbDiag2 + rank + file];
UINT64 diag1Moves = m_diag1Moves[from][diag1];
UINT64 diag2Moves = m_diag2Moves[from][diag2];
// we remove moves that take the bishops own pieces
UINT64 bitmap = (diag1Moves | diag2Moves) & ~m_colourBoard[m_wtm];
// now we generate the moves
while( bitmap )
{
Square to = BitScanForwardRemove(bitmap);
moves.Add( CMove(cBishop, from, to) );
}
What would your code to generate all the bishop's moves look like?
Cheers, Tim.
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.