private void gen_species() { foreach (Species s in species.Data) { s.reset(); } foreach (Client c in clients.Data) { if (c.Species != null) { continue; } bool found = false; foreach (Species s in species.Data) { if (s.put(c)) { found = true; break; } } if (!found) { species.add(new Species(c)); } } foreach (Species s in species.Data) { s.evaluate_score(); } }
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); }
public Species(Client representative) { this.representative = representative; this.representative.Species = this; clients.add(representative); }