A wireless sensor network relay selection algorithm to balance between power consumption and communication quality of the main sensor network is proposed to enhance the network life cycle. The fuzzy inference system applied to the decision research of the control system has obtained good results. Recently, Brante et al. had confirmed that the fuzzy inference system used in wireless sensor networks relay selection algorithm also had a good performance. It couldn’t be ignored that the fuzzy inference systems are designed with different fuzzy rules based on a state under attack, so there have individual differences in the effectiveness of the security. The study built a security testing system for a wireless sensor network based on the fuzzy system relay selection algorithms to avoid the risk performance. It has extracted valuable experiences from 1.4 million simulation records used to construct fuzzy rules based systems for the safety strategy with identifying function. Through simulations, the study results have confirmed to an effective optimization method proposed by Brante et al. It is sufficient to provide for the relay algorithm designer of wireless sensor networks to effectively improve the safety performance of the fuzzy system relay algorithms.