Author: Gerd Isenberg
Date: 15:59:16 07/14/03
Go up one level in this thread
On July 14, 2003 at 18:42:30, Sune Fischer wrote:
>On July 14, 2003 at 18:26:52, Gerd Isenberg wrote:
>
>>On July 14, 2003 at 17:59:36, Sune Fischer wrote:
>>
>>>On July 14, 2003 at 17:52:06, Gerd Isenberg wrote:
>>>
>>>Hi Gerd
>>>
>>>I was just wondering, you wouldn't happen to know an easy transformation for the
>>>diagonals, so that a table lookup for ths shift could be avoided?
>>>
>>
>>Hi Sune,
>>
>>Not necessary to shift the masked occupied state, only a question of indexing
>>diagonals and byte aligned access (interprete the rotated occupied bitboards as
>>an 8-byte array).
>>
>>Pack the longest diagonal (a1-h8) one in one byte, then length 7 (b1-h7) with
>>opposite length 1 (a8-a8), 6 (c1-h6) with 2 (a7-b8) and so on.
>>Look for an 8-ray index calculated with rank and file indicies of these square.
>>
>>Except calculating the ray index and the tables of course, diagonal lookup code
>>is the same as for ranks or files.
>>
>>>Somehow that shift bothers me, it should be possible to compute it on the fly I
>>>think.
>>>
>>>-S.
>>
>>"and" with 0x7eh and you have index * 2. So shifting may be avoided due to 4
>>multiplier in address calculation.
>
>You've lost me here :)
>
>How does anding with 0x7eh multiply index by 2, what has it got to do with the
>index?
One ray is one byte. The "inner" bits are 01111110B = 0x7e.
To get a BitBoard index of the six inner squares you have to divide by two
or shift right one (and you must do it in a c-program), result 0x3f.
>
>Anyway, perhaps I should have been more clear, here is the one attack macro:
>
>#define AttackL45(s,o) (BishopL45[s][((o)>>ShiftL45[s])&63])
>
>It's the ShiftL45 lookup I'd like to avoid, that transformation is not so easy.
>I thought maybe there was a magic trick :)
>
Read again, the ShiftL45[s] lookup is not necessary.
__forceinline
BitBoard A1H8Attacks(unsigned int sq) const
{
return sA1H8Atta[sq]
[(*(((BYTE*)&(m_OccuBBA1H8))+((sq-Rank(sq))&7))&0x7e)>>1];
// diaindex = (file-rank) & 7
}
Gerd
>-S.
>
>>Regards,
>>Gerd
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.