public virtual void mutate_node() { ConnectionGene con = connections.random_element(); if (con == null) { return; } NodeGene from = con.From; NodeGene to = con.To; int replaceIndex = neat.getReplaceIndex(from, to); NodeGene middle; if (replaceIndex == 0) { middle = neat.Node; middle.X = (from.X + to.X) / 2; middle.Y = (from.Y + to.Y) / 2 + GlobalRandom.NextDouble * 0.1 - 0.05; neat.setReplaceIndex(from, to, middle.Innovation_number); } else { middle = neat.getNode(replaceIndex); } ConnectionGene con1 = neat.getConnection(from, middle); ConnectionGene con2 = neat.getConnection(middle, to); con1.Weight = 1; con2.Weight = con.Weight; con2.Enabled = con.Enabled; connections.remove(con); connections.add(con1); connections.add(con2); nodes.add(middle); }