Author: Gerd Isenberg
Date: 23:45:26 03/25/04
Go up one level in this thread
On March 25, 2004 at 18:49:34, Gerd Isenberg wrote:
>On March 25, 2004 at 18:30:17, Gerd Isenberg wrote:
>
>>On March 25, 2004 at 08:36:18, Vasik Rajlich wrote:
>>
>>>On March 24, 2004 at 18:59:02, Gerd Isenberg wrote:
>>>
>>>>Some minor changes because inOne == inThree is not general enough.
>>>>Better to look for no further growing:
>>>>if ( (inThree & ~(fromBB|inOne|inTwo)) == 0 && ...
>>>>
>>>>
>>>>// fixed is subset of tabu (may be equal), the set of all own blocked
>>>>// and backward pawns.
>>>>// tabu may contain enemy pawn attacks which don't terminate the attack ray
>>>>
>>>>BitBoard getTrappedBishopSquares(BitBoard fixed, BitBoard tabu, int n)
>>>>{
>>>> BitBoard trappedBishopSquares = 0;
>>>> BitBoard potb = ~tabu;
>>>> while ( potb ) {
>>>> BitBoard fromBB = potb & -potb;
>>>> BitBoard inOne = fillBishopAttacks(fromBB, ~fixed) & ~tabu;
>>>> BitBoard inTwo = fillBishopAttacks(inOne, ~fixed) & ~tabu;
>>>> BitBoard inThree = fillBishopAttacks(inTwo, ~fixed) & ~tabu;
>>>> // tag all reachable in up to three moves as done
>>>> potb &= ~(fromBB|inOne|inTwo|inThree);
>>>> inThree &= ~(fromBB|inOne|inTwo); // growing?
>>>> if ( inThree == 0 && popCount(inOne|inTwo) < n )
>>>> trappedBishopSquares |= (fromBB|inOne|inTwo);
>>>> }
>>>> return trappedBishopSquares;
>>>>}
>>>>
>>>>popCount > n considers the whole fill area reachable in two moves.
>>>
>>>Gerd,
>>>
>>>thanks, I'll try it in Rybka.
>>
>>I'll too in IsiChessXMM ;-)
>>
>>As Sune already mentioned,
>>
>>fillBishopOccluded(fromBB, ~tabu)
>>
>>is a bit faster (one 64-bit shift,two ands less for each of four directions)
>>than
>>
>>fillBishopAttacks(fromBB, ~tabu) & ~tabu;
>>
>>But the latter has the option, to distinguish between mechanical own fixed pawns
>>(or defended enemy pawns) and additional enemy pawn controls ...
>>
>>fillBishopAttacks(fromBB, ~fixed) & ~tabu;
>
>
>oups wrong! fillOccluded is still faster here than getAttacks and may even
>supplied with an additional masking out of enemy pawn attacks.
>
>fillBishopOccluded(fromBB, ~fixed) & ~tabu;
>
>
>
>// fixed is subset of taboo (may be equal), the set of all own blocked
>// and backward pawns.
>// tabu may contain enemy pawn attacks which don't terminate the attack ray
>
>BitBoard getTrappedBishopSquares(BitBoard fixed, BitBoard taboo, int n)
>{
> BitBoard trappedBishopSquares = 0;
> BitBoard potb = ~taboo;
> while ( potb ) {
> BitBoard fromBB = potb & -potb;
> BitBoard inOne = fillBishopOccluded(fromBB, ~fixed) & ~taboo;
> BitBoard inTwo = fillBishopOccluded(inOne, ~fixed) & ~taboo;
> BitBoard inThree = fillBishopOccluded(inTwo, ~fixed) & ~taboo;
> // tag all reachable in up to three moves as done
> potb &= ~inThree;
> inThree &= ~inTwo; // growing?
> if ( inThree == 0 && popCount(inTwo) < n )
> trappedBishopSquares |= inTwo;
> }
> return trappedBishopSquares;
>}
Some more notes about n in this algo.
With 3 consecutive fills n should be not greater than 3+1.
Otherwise there are cases, where the traversing order may influence the result.
[D] 8/2b5/5p1k/1p1p4/pP1Pp2K/P1P1P3/5P2/2B5 w - -
Eg. with n == 6 in this position, the bishop on c1 doesn't grow after two fills.
{a1,b2,c1,d2,e1} is consired trapped. But bishops on a1,b2,d2,e1 still grow by
one more square after two fills. With n == 4 whole bishops are not considered
trapped - otherwise one has to use one or two more fill cycles...
One more reason to use Sune's approach!
Anyway, the corrected one...
// fixed is subset of taboo (may be equal), the set of all own blocked
// and backward pawns.
// tabu may contain enemy pawn attacks which don't terminate the attack ray
BitBoard getTrappedBishopSquares(BitBoard fixed, BitBoard taboo)
{
BitBoard trappedBishopSquares = 0;
BitBoard potb = ~taboo;
while ( potb ) {
BitBoard fromBB = potb & -potb;
BitBoard inOne = fillBishopOccluded(fromBB, ~fixed) & ~taboo;
BitBoard inTwo = fillBishopOccluded(inOne, ~fixed) & ~taboo;
BitBoard inThree = fillBishopOccluded(inTwo, ~fixed) & ~taboo;
// tag all reachable in up to three moves as done
potb &= ~inThree;
inThree &= ~inTwo; // growing?
if ( inThree == 0 && popCount(inTwo) < 4 )
trappedBishopSquares |= inTwo;
}
return trappedBishopSquares;
}
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.