------------------------------------------------------------------------------
-- Legality check (fast). Check if the moving piece is not pinned. King is
-- also handled here.
ok :: Board -> BitBoard -> Move -> Bool
ok b pins' m = case m^.piece of
  King -> legal b m
  _    ->
    (pins' .&. fromSquare (m^.from)) == mempty -- not pinned
    -- or pinned, but staying in line with the King
    || lineBB (myKingPos b) (m^.to) .&. fromSquare (m^.from) /= mempty
    || lineBB (myKingPos b) (m^.from) .&. fromSquare (m^.to) /= mempty


------------------------------------------------------------------------------
-- Legality check (slow). Makes the move and then checks whether our own king
-- is in check
ok :: Board -> BitBoard -> Move -> Bool
ok b pins' m = case m^.piece of
  King -> legal b m
  _    ->
    (pins' .&. fromSquare (m^.from)) == mempty -- not pinned
    -- or pinned, but staying in line with the King
    || lineBB (myKingPos b) (m^.to) .&. fromSquare (m^.from) /= mempty
    || lineBB (myKingPos b) (m^.from) .&. fromSquare (m^.to) /= mempty


------------------------------------------------------------------------------
-- Legality check (slow). Makes the move and then checks whether our own king
-- is in check
ok b pins' m = case m^.piece of
  King -> legal b m
  _    ->
    (pins' .&. fromSquare (m^.from)) == mempty -- not pinned
    -- or pinned, but staying in line with the King
    || lineBB (myKingPos b) (m^.to) .&. fromSquare (m^.from) /= mempty
    || lineBB (myKingPos b) (m^.from) .&. fromSquare (m^.to) /= mempty


------------------------------------------------------------------------------
-- Legality check (slow). Makes the move and then checks whether our own king
-- is in check