Пример #1
0
 private static Organism getParent(Organism[] os)
 {
     Organism result;
     do {
         result = os[generator.Next(0,os.Length)];
     } while(!result.canReproduce && organisms.Count > 1);
     return result;
 }
Пример #2
0
        private static Organism[] getTwoParents(List<Organism> organisms)
        {
            Organism[] os = organisms.ToArray();
            Organism[] parents = new Organism[2];

            parents[0] = getParent(os);

            do
            {
                parents[1] = getParent(os);
            } while (parents[0] == parents[1]);

            return parents;
        }