------------------------------------------------------------------------------
castleMoves :: Board -> Bool -> [ Move ]
castleMoves b chk = do
  side <- toCastleList $ b^.castleRightsByColour (b^.next)
  let kRays     = magic Rook (eKingPos b) (occupancy b)
      (f, t)    = kingCastleMove (b^.next) side
      rt        = toEnum $ (fromEnum f + fromEnum t) `div` 2
      checkSqrs = toList $ checkCastleBB (b^.next) side
  guard $ chk /= (fromSquare rt .&. kRays == mempty)
  guard $ (vacancyCastleBB (b^.next) side .&. occupancy b) == mempty
  guard $ not $ F.any (isAttacked b (b^.B.opponent)) checkSqrs
  return
    $ (castle .~ Just side)
    $ defaultMove f t King $ b^.next


------------------------------------------------------------------------------
castleMoves :: Board -> Bool -> [ Move ]
castleMoves b chk = do
  side <- toCastleList $ b^.castleRightsByColour (b^.next)
  let kRays     = magic Rook (eKingPos b) (occupancy b)
      (f, t)    = kingCastleMove (b^.next) side
      rt        = toEnum $ (fromEnum f + fromEnum t) `div` 2
      checkSqrs = toList $ checkCastleBB (b^.next) side
  guard $ chk /= (fromSquare rt .&. kRays == mempty)
  guard $ (vacancyCastleBB (b^.next) side .&. occupancy b) == mempty
  guard $ not $ F.any (isAttacked b (b^.B.opponent)) checkSqrs
  return
    $ (castle .~ Just side)
    $ defaultMove f t King $ b^.next


------------------------------------------------------------------------------
castleMoves b chk = do
  side <- toCastleList $ b^.castleRightsByColour (b^.next)
  let kRays     = magic Rook (eKingPos b) (occupancy b)
      (f, t)    = kingCastleMove (b^.next) side
      rt        = toEnum $ (fromEnum f + fromEnum t) `div` 2
      checkSqrs = toList $ checkCastleBB (b^.next) side
  guard $ chk /= (fromSquare rt .&. kRays == mempty)
  guard $ (vacancyCastleBB (b^.next) side .&. occupancy b) == mempty
  guard $ not $ F.any (isAttacked b (b^.B.opponent)) checkSqrs
  return
    $ (castle .~ Just side)
    $ defaultMove f t King $ b^.next


------------------------------------------------------------------------------