private void LinkMutation(long sourceNodeInnovation, float weight) //HACK LinkMutation(long sourceNodeInnovation, float weight) - recurrent links are possible. We may disable this later.
    {
        string debugMsg = "LinkMutation on link with innovation " + sourceNodeInnovation + " using a weight of " + weight;

        if (ArtGallery.DEBUG_LEVEL > ArtGallery.DEBUG.NONE)
        {
            Debug.Log(debugMsg);
        }

        long targetNodeInnovation = GetRandomNodeInnovation(sourceNodeInnovation, false);

        NTYPE sourceNTYPE = GetNodeByInnovationID(sourceNodeInnovation).nTYPE;
        NTYPE targetNTYPE = GetNodeByInnovationID(targetNodeInnovation).nTYPE;


        if (
            /* (sourceNTYPE == NTYPE.INPUT && targetNTYPE == NTYPE.INPUT) ||    // both inputs */
            (sourceNTYPE == NTYPE.INPUT && targetNTYPE == NTYPE.HIDDEN) ||  // input -> hidden
            (sourceNTYPE == NTYPE.INPUT && targetNTYPE == NTYPE.OUTPUT) ||  // input -> output
            /* (sourceNTYPE == NTYPE.HIDDEN && targetNTYPE == NTYPE.HIDDEN) || // hidden -> hidden */
            (sourceNTYPE == NTYPE.HIDDEN && targetNTYPE == NTYPE.OUTPUT))   // hidden -> output
        {
            long link = EvolutionaryHistory.NextInnovationID();
            AddLink(sourceNodeInnovation, targetNodeInnovation, weight, link);
        }
    }
Exemple #2
0
 /// <summary>
 /// New node with no target. Frozen by default
 /// </summary>
 /// <param name="fType">Activation function</param>
 /// <param name="nType">Node type</param>
 /// <param name="innovation">Uniqu innovation number for node</param>
 /// <param name="frozen">True if new link mutations cannot target this node</param>
 /// <param name="bias">Bias offset added to neuron sum before activation. Primarily needed by substrate networks from CPPNs</param>
 public TWEANNNode(FTYPE fType, NTYPE nType, long innovation, bool frozen, float bias)
 {
     this.fType      = fType;
     this.nType      = nType;
     this.innovation = innovation;
     this.frozen     = frozen;
     this.bias       = bias;
     outputs         = new List <TWEANNLink>();
     Flush();
 }
Exemple #3
0
 public NodeGene(NTYPE nTYPE, FTYPE fTYPE, long innovation) : base(innovation)
 {
     this.fTYPE = fTYPE;
     this.nTYPE = nTYPE;
     bias       = 0.0f;
 }
Exemple #4
0
 public FullNodeGene(NTYPE nType, FTYPE fType, long innovation, float bias) : base(nType, fType, innovation)
 {
     this.bias = bias;
 }
Exemple #5
0
 /// <summary>
 /// New node with no target. Frozen by default
 /// </summary>
 /// <param name="fType">Activation function</param>
 /// <param name="nType">Node type</param>
 /// <param name="innovation">Unique innovation number for node</param>
 /// <param name="bias">Bias offset added to neuron sum before activation. Primarily needed by substrate networks from CPPNs</param>
 public TWEANNNode(FTYPE fType, NTYPE nType, long innovation, float bias) : this(fType, nType, innovation, false, bias)
 {
 }
Exemple #6
0
    // TODO any other vars needed to create a graphical output goes here

    /// <summary>
    /// New node with no target. Frozen by default
    /// </summary>
    /// <param name="fType">Activation function</param>
    /// <param name="nType">Node type</param>
    /// <param name="innovation">Uniqu innovation number for node</param>
    public TWEANNNode(FTYPE fType, NTYPE nType, long innovation) : this(fType, nType, innovation, 0.0f)
    {
    }