---------------------------------------------
                -- Move generation in case we are in check --
                ---------------------------------------------

------------------------------------------------------------------------------
defendCheck :: Board -> BitBoard -> [ Move ]
defendCheck b checkers =
  let numCheckers = popCount checkers
  in case numCheckers of
    1 -> let checker = head $ toList checkers
         in captureChecker b checker ++ blockSlider b checker ++ moveKing b
    2 -> moveKing b
    _ -> error "unexpected number of checkers"


------------------------------------------------------------------------------
-- Captures the checking piece (generates pseudo legal moves)
defendCheck :: Board -> BitBoard -> [ Move ]
defendCheck b checkers =
  let numCheckers = popCount checkers
  in case numCheckers of
    1 -> let checker = head $ toList checkers
         in captureChecker b checker ++ blockSlider b checker ++ moveKing b
    2 -> moveKing b
    _ -> error "unexpected number of checkers"


------------------------------------------------------------------------------
-- Captures the checking piece (generates pseudo legal moves)
defendCheck b checkers =
  let numCheckers = popCount checkers
  in case numCheckers of
    1 -> let checker = head $ toList checkers
         in captureChecker b checker ++ blockSlider b checker ++ moveKing b
    2 -> moveKing b
    _ -> error "unexpected number of checkers"


------------------------------------------------------------------------------
-- Captures the checking piece (generates pseudo legal moves)