The code is written in C++ and runs on a standard PC with four CPU cores at 3.4 GHz. The physics simulation is done with the Bullet31 physics engine with a simulation step of 5 ms. Our single-thread implementation runs in real time during the online simulation, while the optimization process runs with the technique of multi-thread, costing around 10 hours for Stage I and 22 hours for Stage II on the aforementioned hardware. In comparison to the discretized look-up table11, our work provides a continuous mapping with comparable timecost. Our method also avoids manually selecting the value of the substep width which critically determines the quality and time performance of the look-up table method11,32. During the optimization, the simulation for each individual is run for 100 seconds (or 100 locomotion cycles) for Stage I, or 10 seconds (or 10 locomotion cycles) for Stage II, or is terminated in advance if the body falls down (the height of body center falls below a threshold). Figure 4 gives a screenshot of the locomotion sequence of a virtual ant in a variety of scenarios.Figure 4Screenshot of locomotion sequence of a virtual ant. (a) Walking straight forward. (b) Walking along a curve. (c) Walking on uneven terrain.