Author: Sune Fischer
Date: 01:33:40 09/14/02
Go up one level in this thread
On September 14, 2002 at 04:10:46, Sune Fischer wrote: >On September 13, 2002 at 20:28:01, Steffan Westcott wrote: > >> >>Here is some more material for people interested in flood-fill based algorithms, >>of the ilk I first mentioned in this article : >>http://www.talkchess.com/forums/1/message.html?251180 >> >>The following routine determines if a path of set bits in 'path' 8-way connect >>(ie. king move) any set bit in sq1 with any set bit in sq2 (this is the same as >>SquaresAreConnected). Also, it will return an array of bitboards showing all >>possible shortest paths - This is probably best explained by showing an example >>: > >Got it :) > >I just thought of another application on the passed pawns. >This way one doesn't need a 8x64 byte table or calls to firstone(). >I can't say if it's faster than the lookup though, I'll probably >use it anyway. > >//=================================================================== >// find the passed and semi-passed pawns: > >BITBOARD WhitePassedPawns(BITBOARD w_pawns,BITBOARD b_pawns) { > BITBOARD passed=0,tempA,tempB; > int i=0; > > tempA=(w_pawns<<8)&~b_pawns; > while (tempA) { > tempB=tempA&rank8; > i+=8; > if (tempB) // a pawn has reached the 8th rank > passed|=tempB>>i; // shift it back to where it originally came from > tempA=(tempA<<8)&~b_pawns; > } > return passed; >} > >//=================================================================== > >(disclamer: I didn't test it, but you get the idea) > >-S. Actually this may be faster, on 64 bit chips anyway: while (tempA) { passed|=(tempA&rank8)>>(i+=8); tempA=(tempA<<8)&~b_pawns; } -S.
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.