Author: Miguel A. Ballicora
Date: 17:14:25 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 If I understood right, that is exactly what I do in Gaviota to calculate the distance from a King to the closest target. In fact, Square B could be a bitboard of possible targets. Miguel > >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.
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.