------------------------------------------------------------------------------
-- | Pseudo legal moves
moves :: Board -> [ PseudoLegalMove ]
moves b =
  let checkers = attackedFromBB b (occupancy b) (b^.B.opponent) (myKingPos b)
      cs = simpleChecks b
           ++ discoveredChecks b
           ++ pawnSimpleChecks b
           ++ pawnDiscoveredChecks b
           ++ castleChecks b
      ps = pawnCapturesSorted b
           ++ pawnPromotions b
           ++ capturesSorted b
           ++ pawnEnPassants b
      ts = castleQuiet b
      nq = quietMovesSorted b ++ pawnQuietMovesSorted b
  in map PseudoLegalMove $ if checkers /= mempty
                           then defendCheck b checkers
                           else cs ++ ps ++ ts ++ nq
moves :: Board -> [ PseudoLegalMove ]
moves b =
  let checkers = attackedFromBB b (occupancy b) (b^.B.opponent) (myKingPos b)
      cs = simpleChecks b
           ++ discoveredChecks b
           ++ pawnSimpleChecks b
           ++ pawnDiscoveredChecks b
           ++ castleChecks b
      ps = pawnCapturesSorted b
           ++ pawnPromotions b
           ++ capturesSorted b
           ++ pawnEnPassants b
      ts = castleQuiet b
      nq = quietMovesSorted b ++ pawnQuietMovesSorted b
  in map PseudoLegalMove $ if checkers /= mempty
                           then defendCheck b checkers
                           else cs ++ ps ++ ts ++ nq
moves b =
  let checkers = attackedFromBB b (occupancy b) (b^.B.opponent) (myKingPos b)
      cs = simpleChecks b
           ++ discoveredChecks b
           ++ pawnSimpleChecks b
           ++ pawnDiscoveredChecks b
           ++ castleChecks b
      ps = pawnCapturesSorted b
           ++ pawnPromotions b
           ++ capturesSorted b
           ++ pawnEnPassants b
      ts = castleQuiet b
      nq = quietMovesSorted b ++ pawnQuietMovesSorted b
  in map PseudoLegalMove $ if checkers /= mempty
                           then defendCheck b checkers
                           else cs ++ ps ++ ts ++ nq