Author: Gerd Isenberg
Date: 15:12:19 09/09/02
Go up one level in this thread
On September 09, 2002 at 17:53:27, Sven Reichard wrote: >Gerd, > >I'm not exactly sure I understand the problem right. If I do, you have a >bitboard, and you want to walk a King from A to B stepping only on "on" squares >(we assume, A and B are on). > >The (non-recursive) algorithm I can come up with is the following (excuse the >pseude-code: > >procedure existsKingWalk(Square A, Square B, BitBoard allowed) > Bitboard reachable, oldReachable > clear(reachable) > set(reachable, A) > do > oldReachable = reachable > for all directions dir do > reachable |= (oldreachable shifted by dir) > od > reachable &= allowed > while reachable <> oldReachable and not reachable[B] > return reachable[B] >end > >I haven't tested it, but it should be faster than checking each individual bit. >This can be modified to get the whole connectivity component (all squares the >king can reach). > >Sven. Yes Sven, that is exactly what i meant, Thanks, great. I'll have a closer look to your code (and translate into c). Not yet completely understood. Quite confused with the "reachable" statements. A global array and a local bitboard? Isn't the loop over all directions equivalent to my bitboard traversion? 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.