The structural design of civil works is closely tied to empirical knowledge and the design professional’s experience. Based on this, adequate designs are generated in terms of strength, operability, and durability. However, such designs can be optimized to reduce conditions associated with the structure’s design and execution, such as costs, CO2 emissions, and related earthworks. In this study, a new discretization technique based on reinforcement learning and transfer functions is developed. The application of metaheuristic techniques to the retaining wall problem is examined, defining two objective functions: cost and CO2 emissions. An extensive comparison is made with various metaheuristics and brute force methods, where the results show that the S-shaped transfer functions consistently yield more robust outcomes.