Author: Sven Reichard
Date: 14:53:27 09/09/02
Go up one level in this thread
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.
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.