Ejemplo n.º 1
0
        internal static List <Ameba> TryToProcreate(Ameba ameba1)
        {
            List <Ameba> listOfThree = new List <Ameba>();
            int          numberWhichDetermines;

            numberWhichDetermines = rnd1.Next(1, 4); //inclusive 1 exclusive 4...so random number between 1 and 3
            //Console.WriteLine(numberWhichDetermines);
            if (numberWhichDetermines == 1)          //dies
            {
                ameba1.die();
                listOfThree.Add(ameba1);
                return(listOfThree);
            }
            else if (numberWhichDetermines == 2) //splits in two and ages...which i just now realized age is pointless
            {
                ameba1.ageYear();
                Ameba ameba2 = new Ameba();
                listOfThree.Add(ameba1);
                listOfThree.Add(ameba2);
                return(listOfThree);
            }
            else //splits in three and ages the first one...which i just now realized age is pointless
            {
                ameba1.ageYear();
                Ameba ameba2 = new Ameba();
                Ameba ameba3 = new Ameba();
                listOfThree.Add(ameba1);
                listOfThree.Add(ameba2);
                listOfThree.Add(ameba3);
                return(listOfThree);
            }
        }
Ejemplo n.º 2
0
        public static void runMain()
        {
            Console.WriteLine("Running Main Method");

            List <Ameba> initialAmebaList = new List <Ameba>();

            for (int i = 0; i < 1000; i++)
            {
                Ameba ameba = new Ameba();
                initialAmebaList.Add(ameba);
            }
            Console.WriteLine("The Number of Amebas in this list is: " + initialAmebaList.Count);
            Console.WriteLine("Starting the iterations of life cycles");

            List <Ameba> listAfterLifeCycles = LifeCycleIterator.IterateNumberOfLifeCylces(initialAmebaList, 1000);

            Console.WriteLine("The number of Amebas after 1000 life cycles is: " + listAfterLifeCycles.Count);
        }