Author: Gerd Isenberg
Date: 15:27:35 09/09/02
Go up one level in this thread
On September 09, 2002 at 17:52:45, Robert Hyatt wrote: >On September 09, 2002 at 16:13:00, Gerd Isenberg wrote: > >>Hi all, >>specially algorithm freaks, >> >>I'm currently looking for an efficient algorithm to determine whether two bits >>in a bitboard are connected by "ones". Actually i use following recursive one, >>but isn't there something smarter? >> >> >>bool isConnected(BitBoard &theBB, int from, int to) >>{ >> BitBoard adjacentBB = KingAttacks(from) & theBB; >> theBB &= ~adjacentBB; >> while (adjacentBB) >> { >> int sq = findLSBAndReset(adjacentBB); >> if (sq == to) return true; >> if ( isConnected(theBB, sq, to) ) return true; >> } >> return false; >>} > >Precompute a table, char connected[64][64]. If square I and J are connected, >for any value of I and J, set connected[I][J]=1, else set it to zero. > >Now you have a quick test. > >If you are wanting to see if a rook is connected to another rook, that is >a different issue... > Thanks Bob, Sounds great, have to think about... But as far i IMHO believe to understand you have to reinitialize the whole array if your position and the "allowed-set" changed . Isn't that too expensive, if you only want to know on the fly whether the king on a1 may walk to b8? Gerd <snip>
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.