Example #1
0
    void OnEnable()  //set up inital nodes and connections
    {
        gt      = new GeneTracker();
        genome  = new Genome(gt);
        nodes   = new List <NodeGene>();
        species = new List <Species>();
        for (int i = 0; i < inputSize; i++)
        {
            NodeGene nodeIn = new NodeGene(NodeGene.NODETYPE.INPUT, gt.NewId(), 0, false, NodeGene.ACTIVATION_FUNCTION.NULL);
            nodes.Add(nodeIn);
            genome.AddNodeGene(nodeIn.Copy());
        }
        for (int i = 0; i < outputSize; i++)
        {
            NodeGene nodeOut = new NodeGene(NodeGene.NODETYPE.OUTPUT, gt.NewId(), 1, true, outputActiationFunction);
            nodes.Add(nodeOut);
            genome.AddNodeGene(nodeOut.Copy());
        }


        connections = new List <ConnectionGene>();


        for (int i = 0; i < inputSize; i++)
        {
            for (int i2 = 0; i2 < outputSize; i2++)
            {
                //Debug.Log(genome.GetNodeGenes()[i]);
                ConnectionGene con = new ConnectionGene(genome.GetNodeGenes()[i], genome.GetNodeGenes()[inputSize + i2], gt.Innovate());
                connections.Add(con.Copy());
            }
        }
        for (int i = 0; i < connections.Count; i++)
        {
            //Debug.Log(connections[i]);
        }
    }