public ConnectionGene(ConnectionGene Connection) { if (Connection != null) { this.InputNode = Connection.GetInputNode(); this.OutputNode = Connection.GetOutputNode(); this.Weight = Connection.GetWeight(); this.IsEnabled = Connection.GetEnabled(); this.Innovation = Connection.GetInnovation(); } }
public void MutateAddNode() { ConnectionGene randomConnection = GetConnectionGenes()[random.Next(GetConnectionGenes().Count)]; NodeGene InNode = GetNodeGenes()[randomConnection.GetInputNode()]; NodeGene OutNode = GetNodeGenes()[randomConnection.GetOutputNode()]; randomConnection.SetEnabled(false); NodeGene MiddleNode = new NodeGene(GetNodeGenes().Count + 1, NodeGene.TYPE.HIDDEN, 0); ConnectionGene InputToMiddle = new ConnectionGene(InNode.GetID(), MiddleNode.GetID(), 1, true, NEAT_CONFIGS.GLOBAL_INNOVATION_NUMBER++); ConnectionGenes.Add(InputToMiddle); MiddleNode.AddIncomingConnection(InputToMiddle); ConnectionGene MiddleToOutput = new ConnectionGene(MiddleNode.GetID(), OutNode.GetID(), randomConnection.GetWeight(), true, NEAT_CONFIGS.GLOBAL_INNOVATION_NUMBER++); ConnectionGenes.Add(MiddleToOutput); OutNode.AddIncomingConnection(MiddleToOutput); //Add to the total current Pool Connections Made in this instance NodeGenes.Add(MiddleNode.GetID(), MiddleNode); }