This paper proposes a new naturally inspired swarm intelligence algorithm called the Aptenodytes Forsteri Optimization Algorithm (AFO). The main inspiration is the emperor penguin’s warm-hugging behaviour. When looking for a suitable location, emperor penguins need to sense the change of temperature, consider the location of other penguins, move closer to the centre of the penguin population, minimize their energy loss, and refer to their memory. These five strategies are evolved into five update modes of variables. According to the characteristics of these update modes in the exploration and exploitation stage, adaptive adjustment methods are designed to mix the five ways. The effectiveness of the proposed AFO is checked, through a comparison with other nature-inspired algorithms, on shifted classical benchmark problems and CEC2017 benchmark problems. Moreover, four engineering problems are utilized to estimate the effectiveness of AFO in optimizing constrained problems. The experimental results show that AFO has the best performance in most problems, which can be considered an excellent and competitive algorithm. In addition, as for the problem of partial algorithm update bias towards the origin, particular experiments and metrics are designed to examine the impact of such update methods on the generality of the algorithm. Source codes of AFO are publicly available at https://github.com/TwilightArchonYz/A-new-Nature-inspired-optimization-algorithm-AFO.