Ejemplo n.º 1
0
        public bool Contains(Innovation innov)
        {
            switch (innov.type)
            {
            case InnovationType.Neuron:
                return(neuronGenes.Contains(innov.innovationId));

            case InnovationType.Synapse:
                return(synapseGenes.Contains(innov.innovationId));

            default:
                return(false);
            }
        }
        public int GetSynapseInnovationId(int fromNeuronId, int toNeuronId)
        {
            foreach (var innov in innovations) {
            if (innov.type == InnovationType.Synapse &&
            innov.fromNeuronId == fromNeuronId &&
            innov.toNeuronId == toNeuronId) {
              return innov.innovationId;
            }
              }

              var innovation = new Innovation(InnovationType.Synapse, nextInnovationId, fromNeuronId, toNeuronId, -1);
              innovations.Add(innovation);

              nextInnovationId++;
              return innovation.innovationId;
        }
        public int GetNeuronInnovationId(int fromNeuronId, int toNeuronId, int oldSynapseInnovationId)
        {
            foreach (var innov in innovations) {
            if (innov.type == InnovationType.Neuron &&
            innov.fromNeuronId == fromNeuronId &&
            innov.toNeuronId == toNeuronId &&
            innov.oldSynapseInnovationId == oldSynapseInnovationId) {
              return innov.innovationId;
            }
              }

              var innovation = new Innovation(InnovationType.Neuron, nextInnovationId, fromNeuronId, toNeuronId, oldSynapseInnovationId);
              innovations.Add(innovation);

              nextInnovationId += 2; // We increment by 2: once for each synapse
              return innovation.innovationId;
        }
Ejemplo n.º 4
0
        public int GetSynapseInnovationId(int fromNeuronId, int toNeuronId)
        {
            foreach (var innov in innovations)
            {
                if (innov.type == InnovationType.Synapse &&
                    innov.fromNeuronId == fromNeuronId &&
                    innov.toNeuronId == toNeuronId)
                {
                    return(innov.innovationId);
                }
            }

            var innovation = new Innovation(InnovationType.Synapse, nextInnovationId, fromNeuronId, toNeuronId, -1);

            innovations.Add(innovation);

            nextInnovationId++;
            return(innovation.innovationId);
        }
        public int GetInitialNeuronInnovationId(int i)
        {
            foreach (var innov in innovations) {
            if (innov.type == InnovationType.Neuron &&
            innov.innovationId == i) {
              return innov.innovationId;
            }
              }

              // Catch up (in case we fell behind by index)
              if (nextInnovationId < i) {
            nextInnovationId += i - nextInnovationId;
              }

              var innovNext = new Innovation(InnovationType.Neuron, nextInnovationId, -1, 1, -1);
              nextInnovationId++;

              innovations.Add(innovNext);
              return innovNext.innovationId;
        }
Ejemplo n.º 6
0
        public int GetNeuronInnovationId(int fromNeuronId, int toNeuronId, int oldSynapseInnovationId)
        {
            foreach (var innov in innovations)
            {
                if (innov.type == InnovationType.Neuron &&
                    innov.fromNeuronId == fromNeuronId &&
                    innov.toNeuronId == toNeuronId &&
                    innov.oldSynapseInnovationId == oldSynapseInnovationId)
                {
                    return(innov.innovationId);
                }
            }

            var innovation = new Innovation(InnovationType.Neuron, nextInnovationId, fromNeuronId, toNeuronId, oldSynapseInnovationId);

            innovations.Add(innovation);

            nextInnovationId += 2; // We increment by 2: once for each synapse
            return(innovation.innovationId);
        }
Ejemplo n.º 7
0
        public int GetInitialNeuronInnovationId(int i)
        {
            foreach (var innov in innovations)
            {
                if (innov.type == InnovationType.Neuron &&
                    innov.innovationId == i)
                {
                    return(innov.innovationId);
                }
            }

            // Catch up (in case we fell behind by index)
            if (nextInnovationId < i)
            {
                nextInnovationId += i - nextInnovationId;
            }

            var innovNext = new Innovation(InnovationType.Neuron, nextInnovationId, -1, 1, -1);

            nextInnovationId++;

            innovations.Add(innovNext);
            return(innovNext.innovationId);
        }
 public bool Contains(Innovation innov)
 {
     switch (innov.type) {
     case InnovationType.Neuron:
       return neuronGenes.Contains(innov.innovationId);
     case InnovationType.Synapse:
       return synapseGenes.Contains(innov.innovationId);
     default:
       return false;
       }
 }