Author: Steven Edwards
Date: 11:07:37 05/09/05
Go up one level in this thread
On May 09, 2005 at 10:19:23, Gerd Isenberg wrote: >On May 09, 2005 at 07:48:51, Steven Edwards wrote: >>The actual code for FirstSq/NextSq will depend on the specific bit/square >>correspondance. For Symbolic's toolkit, the CTBB::NextSq() member function is: >> >>#if (CTHostMac && CTArchBits32 && CTAllowAssembly) >> CTSq NextSq(void) >> { >> int theZC = __cntlzw(myDwrdVec[0]); >> >> if (theZC != 32) >> { >> myDwrdVec[0] ^= 1 << (31 - theZC); >> return (CTSq) (theZC ^ 0x07); >> } >> else >> { >> theZC = __cntlzw(myDwrdVec[1]); >> if (theZC != 32) >> { >> myDwrdVec[1] ^= 1 << (31 - theZC); >> return (CTSq) ((theZC ^ 0x07) + 32); >> } >> else >> return CTSqNil; >> }; >> } >>#endif >>The above "(theZC ^ 0x07)" operations could be removed if the bit/square >>correspondance was altered (reversed) to have a-file squares appear in the MSbit >>instead of the LSBit. I believe this is how Crafty arranges the bits, but I >>haven't tested it. Currently, Crafty does not have assemply language level >>optimizations for PowerPC. Possibly some ambitious author could contribute in >>that area. >confusion about LSBit and MSBit ;-) > >Lets take the first rank with eight binary digits for each file. Bit 0, the most >right is the least significant bit LSBit. I use the "mirrored" mapping LSB = a1 >and MSB = h1, while you seem to map in the "natural" way MSB = a1 and LSB h1? > >MSBit LSBit 2**0 >| | >00000001B 0x01 ; a1 for me - h1 for you >10000000B 0x80 ; h1 for me - a1 for you > >If you traverse a (-1) bitboard (all bits set) with that routine >you receive a kind of "sawtooth": 56,57,..,63, 48,47,..,55,.,..,..,0,1,..,7. >Did i get that correct? No, I get a1, b1, ...h1, a2, ... g8, h8. >May be a bit pedantic to save a subtract and to shift INT_MIN logical right ;-) > > myDwrdVec[0] ^= (unsigned)(1<<31) >> theZC; // >>> >instead of > myDwrdVec[0] ^= 1 << (31 - theZC); The CTBB storage declaration: union { CTByte myByteVec[CTBBByteLen]; CTWord myWordVec[CTBBWordLen]; CTDwrd myDwrdVec[CTBBDwrdLen]; CTQwrd myQwrdVec[CTBBQwrdLen]; }; #define CTBX(base) (1 << (base)) void ResetSq(const CTSq theSq) { myByteVec[theSq >> 3] &= ~CTBX((theSq & 0x07)); } void SetSq(const CTSq theSq) { myByteVec[theSq >> 3] |= CTBX((theSq & 0x07)); } void ResetSq(const CTRank theRank, const CTFile theFile) { myByteVec[theRank] &= ~CTBX(theFile); } void SetSq(const CTRank theRank, const CTFile theFile) { myByteVec[theRank] |= CTBX(theFile); } bool IsReset(const CTSq theSq) const { return !(myByteVec[theSq >> 3] & CTBX((theSq & 0x07))); } bool IsSet(const CTSq theSq) const { return myByteVec[theSq >> 3] & CTBX((theSq & 0x07)); } unsigned int Card(void) const { return CardVec[myWordVec[0]] + CardVec[myWordVec[1]] + CardVec[myWordVec[2]] + CardVec[myWordVec[3]]; } unsigned int CardFew(void) const { unsigned int theCount = 0; CTBitVector theBitVector = GetBitVector(); while (theBitVector) { theCount++; theBitVector &= (theBitVector - 1); }; return theCount; }
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.