Undulatory swimming is a universal locomotion mode, covering dimensions from sperms ( ~ micrometers) to whales (~ meters). It has broad potential in robotic applications in environmental monitoring, remediation, and biomechanical research. To date, many undulatory swimmers have been proposed. However, they can hardly achieve comparable performance as their biological counterparts. As a typical contrast, natural undulatory swimmers can adaptively adjust their distribution of the body stiffness to accommodate different fluidic conditions and achieve improved swimming performances. Given such a challenge, we propose a novel artificial muscle-based stiffness distribution tuning mechanism for undulatory robots and an accompanied CFD-based inverse design methodology for the target stiffness distribution to achieve desired swimming performances. The design iteration with the computation foundation will lead to an autonomous undulatory fish robot that can smartly adapt its body stiffness distribution with superior swimming performance in changing fluidic conditions. The methodology shown here can also help the design and manufacturing of general tendon-driven soft robot such as robotic hands, grippers, and robotic catheters utilizing the benefits of stiffness distribution variation.