Automatic speed control of electric trains is always a matter of attention due to reasons such as safety, travel comfort, and, most importantly, preventing human errors. In order to achieve this goal, the dynamic models of the train and electric motor will be estimated and then simulated. Based on the simulated model and the desired objectives, the controller will be designed by an experienced engineer. During this process, the simulated state space models always encounter errors. Additionally, the controller design process will be conducted offline. Thus, the issue will be addressed by incorporating a state feedback controller and formulating the Bellman equation for reference signal tracking. In order to obtain the state controller parameters, the policy is initially evaluated and subsequently improved. This iterative process will continue until the termination conditions are met. In this process, there is no need for a dynamic model of the system, and the controller parameters will be obtained solely through interaction with the environment. Therefore, even with changes in the train dynamics, the controller will be updated online. The proposed method for determining the values of state feedback parameters will be juxtaposed with other artificial intelligence techniques, including particle swarm optimization, genetic algorithm, and bees algorithm. Evaluation metrics such as root mean square error, coefficient of determination (R-squared), and explained variance will be employed to assess the performance of these algorithms. The results obtained underscore the superior efficacy of the proposed method.