This paper presents the Genetic Algorithm Optimized Fourier Series Formulation (GAOFSF) method for stable gait generation in bipedal locomotion. It uses a Truncated Fourier Series (TFS) formulation with its coefficients determined and optimized by Genetic Algorithm. The GAOFSF method can generate human-like stable gaits for walking on flat terrains as well as on slopes in a uniform way. Through the adjustment of only a single or two parameters, the step length and stride-frequency can easily be adjusted online, and slopes of different gradients are accommodated. Dynamic simulations show the robustness of the GAOFSF, with stable gaits achieved even if the step length and stride frequency are adjusted by significant amounts. With its ease of adjustments to accommodate different gait requirements, the approach lends itself readily for control of walking on a rough terrain and in the presence of external perturbations.