/// <summary> /// given a series of start genes and start neurons this ctor adds all the appropriate innovations /// </summary> /// <param name="start_genes"></param> /// <param name="start_neurons"></param> public Innovation(List <LinkGene> start_genes, List <NeuronGene> start_neurons) { this.NextNeuronID = 0; this.NextInnovationNumber = 0; this.Innovations = new List <InnovationContainer>(); //add the neurons for (int nd = 0; nd < start_neurons.Count; ++nd) { this.Innovations.Add(new InnovationContainer(start_neurons[nd], this.NextInnovationNumber++, this.NextNeuronID++)); } //add the links for (int cGen = 0; cGen < start_genes.Count; ++cGen) { InnovationContainer NewInnov = new InnovationContainer(start_genes[cGen].FromNeuron, start_genes[cGen].ToNeuron, InnovationType.NewLink, this.NextInnovationNumber); this.Innovations.Add(NewInnov); ++this.NextInnovationNumber; } }
/// <summary> /// creates a new innovation and returns its ID /// </summary> /// <param name="input"></param> /// <param name="output"></param> /// <param name="type"></param> /// <returns></returns> public int CreateNewInnovation(int input, int output, InnovationType type) { InnovationContainer new_innov = new InnovationContainer(input, output, type, this.NextInnovationNumber); if (type == InnovationType.NewNeuron) { new_innov.NeuronID = this.NextNeuronID; ++this.NextNeuronID; } this.Innovations.Add(new_innov); ++this.NextInnovationNumber; return(this.NextNeuronID - 1); }
/// <summary> /// as above but includes adding x/y position of new neuron /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="InnovType"></param> /// <param name="NeuronType"></param> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public int CreateNewInnovation(int from, int to, InnovationType innovType, NeuronType neuronType, double x, double y) { InnovationContainer new_innov = new InnovationContainer(from, to, innovType, this.NextInnovationNumber, neuronType, x, y); if (innovType == InnovationType.NewNeuron) { new_innov.NeuronID = this.NextNeuronID; ++this.NextNeuronID; } this.Innovations.Add(new_innov); ++this.NextInnovationNumber; return(this.NextNeuronID - 1); }