An adaptive sliding mode controller (SMC) design with a reinforcement-learning parameter optimization method is proposed for variable-speed trajectory tracking control of underactuated vessels under scenarios involving model uncertainties and external environmental disturbances. First, considering the flexible control requirements of the vessel's propulsion system, the desired navigation speed is designed to satisfy an S-curve acceleration and deceleration process. The rate of change of the trajectory parameters is derived. Second, to address the model uncertainties and external disturbances, an extended state observer (ESO) is designed to estimate the unknown bounded disturbances and to provide feedforward compensation. Moreover, an adaptive law is designed to estimate the upper bound of the unknown disturbances, ensuring system stability even in the presence of asymptotic observation errors. Finally, the Twin-Delayed Deep Deterministic Policy Gradient (TD3) algorithm is employed for real-time controller parameter tuning. Numerical simulation results demonstrate that the proposed method significantly improves the trajectory tracking accuracy and dynamic response speed of the underactuated vessel. Specifically, for a sinusoidal trajectory with an amplitude of 200 m and a frequency of 0.01, numerical results show that the proposed method achieves convergence of the longitudinal tracking error to zero, while the lateral tracking error remains stable within 1 m. For the circular trajectory with a radius of 300 m, the numerical results indicate that both the longitudinal and lateral tracking errors are stabilized within 1 m. Compared with the fixed-value sliding mode controller, the proposed method demonstrates superior trajectory tracking accuracy and smoother control performance.