Пример #1
0
        public void MutateRandomNode()
        {
            List <GSTreeNode> nodes = new List <GSTreeNode>();

            GSTreeTraverse.GetAllFunctionNodes(root, nodes);
            System.Random rand = new System.Random();
            GSTreeNode    node = nodes[rand.Next(nodes.Count)];

            if (GSDictionaries.BasicFunctions.ContainsKey(node.value) ||
                GSDictionaries.DoubleArgFunctions.ContainsKey(node.value))
            {
                node.value = GSDictionaries.GetDifferentDoubleArgFunction(node.value);
            }
            else if (GSDictionaries.SingleArgFunctions.ContainsKey(node.value))
            {
                node.value = GSDictionaries.GetDifferentSingleArgFunction(node.value);
            }
        }