private static ConnectionGene GetMatchingGene(NeatEvaluator evaluator, ConnectionGene connection1, ConnectionGene connection2, float disableInheritChance) { ConnectionGene geneToTake; if (evaluator.GetRandomFloat() < 0.5) { geneToTake = connection1.Copy(null); } else { geneToTake = connection2.Copy(null); } if (connection1.Enabled || connection2.Enabled) { if (!connection1.Enabled || !connection2.Enabled) { geneToTake.Enabled = true; if (evaluator.GetRandomFloat() < disableInheritChance) { geneToTake.Enabled = false; } } } return(geneToTake); }
public bool AddConnection(ConnectionGene connection) { if (Connections.AddNew(connection.Copy(null))) { //IncrementInnovationId(); return(true); } return(false); }
private static ConnectionGene GetGeneFromFitterParent(NeatEvaluator evaluator, Genome fitParent, bool fitnessEqual, ConnectionGene connection, Genome genome) { ConnectionGene geneToTake = null; if (fitnessEqual) { if (evaluator.GetRandomFloat() < 0.5) { geneToTake = connection.Copy(null); } } else { if (genome == fitParent) { geneToTake = connection.Copy(null); } } return(geneToTake); }