public INode MutateAddNode() { int innovation = (int)RandomHelpers.GetRandomBiasingLow( Genes.Min(g => g.Innovation), Genes.Max(g => g.Innovation) ); IGene oldGene = Genes.FirstOrDefault(g => g.Innovation <= innovation); if (oldGene == null) { oldGene = Genes[new Random().Next(Genes.Count)]; } INode newNode = new Node(NodeType.Hidden); // Disable the old connection oldGene.IsExpressed = false; // Add new connections IGene newGeneIn = new Gene( oldGene.NodeOut, newNode, GetNextInnovation(), 1 ); IGene newGeneOut = new Gene( newNode, oldGene.NodeIn, GetNextInnovation(), oldGene.Weight ); Nodes.Add(newNode); Genes.Add(newGeneIn); Genes.Add(newGeneOut); return(newNode); }