code: def board_fen(self, *, promoted: Optional[bool] = False) -> str:
          
          builder = []
          empty = 0
  
          for square in SQUARES_180:
              piece = self.piece_at(square)
  
              if not piece:
                  empty += 1
              else:
                  if empty:
                      builder.append(str(empty))
                      empty = 0
                  builder.append(piece.symbol())
                  if promoted and BB_SQUARES[square] & self.promoted:
                      builder.append("~")
  
              if BB_SQUARES[square] & BB_FILE_H:
                  if empty:
                      builder.append(str(empty))
                      empty = 0
  
                  if square != H1:
                      builder.append("/")
  
          return "".join(builder)
docs: Gets the board FEN.