## 1 Introduction
The investigation results show that CoT could be reduced by choosing a small duty factor and optimal walking velocity. Also, CoT depends highly on the stroke distance and is less when a stroke is longer. Authors say that the wave gait is only appropriate for low walking speed, and different gaits should be used for higher-speed locomotion. So, to save energy it is very important to select the proper gait. Additional research, including a duty factor evaluation, was done by [46]. Analysis of the energy usage of a six-legged robot during its locomotion over flat terrain was presented. The results of this investigation showed that the lowest duty factor of the wave gait gives the lowest energy consumption. CoT depends on the terrain type. Irregular terrain would require more energy expenses than plain terrain. Paper [47] presented a method to optimize the energy use of a hexapod robot on irregular terrain. When the foot trajectories of the legged robot are calculated to minimize energy use during every half a locomotion cycle, it is possible to save about 3.21% of the energy. The energy efficiency of a hexapod robot wave gait was analyzed in [48]. The author used a simulation model to obtain walking measurements using different modes and varying gait parameters. The results presented in this paper suggest that using a wave gait with different leg sequences is better than using a basic wave gait, although using only wave gait is not efficient, overall, as it is only used for the lower speeds as mentioned before [45]. The analysis of the torque distribution algorithm to decrease the energy cost of the hexapod robot (only for wave gait) is presented in [15]. The proposed scheme allowed reducing energy use from 22% to 39% with the use of fitting robot walking speed and duty factor. The advantages of gait switching for statically-stable locomotion of a hexapod robot over various terrain types while using a tripod, amble (tetrapod), and wave gaits were explored in [16]. The results showed that on a hard smooth surface at low speeds (up to ~0.1 m/s) the wave gait has higher CoT than the tripod gait. At speeds of ~0.1 m/s, the tripod gait has the lowest CoT, and increasing speed further decreases CoT (at 0.3 m/s CoT = -15). A similar investigation was done in [49], where locomotion on different surfaces was tested by changing the leg's joint compliance. During each experiment, the robot walked the same distance and the current was measured during its locomotion. Best achieved CoT was 17.2 at a speed of ~0.039 m/s. [PERSON] et al. [50] employed energy usage optimization by introducing equality constraints of dynamic force and moment equilibrium, and inequality constraints of joint torque. Then, they obtained ideal foot forces by solving a quadratic programming (QP) problem. The novelty and contributions of this paper are as follows:  
1. A heuristic gait-switching algorithm to minimize the energy consumption of the hexapod robot. 2. Adoption of a novel nature-inspired Red Fox Optimization (RFO) for gait parameter selection to minimize the CoT value of the hexapod robot, which has been never done before. 3. Experimental study of both algorithms. The remaining parts of the paper are summarized as follows. Section 2 describes the materials and methods used in our research. Section 3 presents the results of our experiments. Section 4 discusses the results and presents conclusions.