Example #1
0
 public void FillPool()
 {
     //Create a new pool of Genomes
     pool = new List <Genome>();
     for (int i = 0; i < _poolSize; i++)
     {
         Genome tempGenome = new Genome(_index, i, _inputCount, _outputCount);
         tempGenome.CreateBasicNodes();
         tempGenome.CreateRandomConnection();
         pool.Add(tempGenome);
     }
 }
Example #2
0
    public List <Genome> FillNewGeneration(List <Genome> oldPool)
    {
        List <Genome> result = ObjectCopier.Clone <List <Genome> >(oldPool);

        for (int i = 0; i < result.Count; i++)
        {
            result[i]._index = i;
        }
        for (int i = 0; i < oldPool.Count; i += 2)
        {
            Genome Offspring1 = new Genome(_index, i + oldPool.Count, oldPool[i]._inputCount, oldPool[i]._outputCount);
            Genome Offspring2 = new Genome(_index, i + 1 + oldPool.Count, oldPool[i]._inputCount, oldPool[i]._outputCount);
            oldPool[i].Mate(oldPool[i + 1], Offspring1, Offspring2);
            Offspring1.CreateBasicNodes();
            Offspring1.CreateExtendedNodes();
            Offspring2.CreateBasicNodes();
            Offspring2.CreateExtendedNodes();
            result.Add(Offspring1);
            result.Add(Offspring2);
        }
        return(result);
    }