示例#1
0
        public static void Vrainiveau2(Grille grille, int nombre)
        {
            Grille grillebis = new Grille(grille.Taille);

            grille.affiche("lol");
            Console.ReadKey();
            Console.Clear();
            for (int c = 0; c < nombre; c++)
            {
                for (int i = 0; i < grille.Taille; i++)
                {
                    for (int j = 0; j < grille.Taille; j++)
                    {
                        grille.Nbvoisin(grille.TableauDeCellules[i, j]);
                        grille.Jeuniveau2(grillebis.TableauDeCellules[i, j], grille.TableauDeCellules[i, j].Nbvoisin);
                    }
                }
                grillebis.clone(grille);
                grille.affiche("lol");

                Console.ReadKey();

                Console.Clear();
            }
        }
示例#2
0
        public static void Main(string[] args)
        {
            //Console.WriteLine("Hello World!");

            // TODO: Implement Functionality Here

            //Console.Write("Press any key to continue . . . ");
            Grille.menu();
            Console.ReadKey(true);
        }
示例#3
0
 public void clone(Grille magrile)
 {
     magrile.Taille = this.Taille;
     for (int i = 0; i < Taille; i++)
     {
         for (int j = 0; j < Taille; j++)
         {
             magrile.TableauDeCellules[i, j].Cloner(this.TableauDeCellules[i, j]);
         }
     }
 }
示例#4
0
        public static void menu()
        {
            Console.WriteLine("choisisez le type de remplissage\n\n1- non aleatoire\n2- aleatoire avec pourcentage\n3- aleatoire avec age et energie a definir");
            int choix_rempli = 0;

            do
            {
                try
                {
                    choix_rempli = int.Parse(Console.ReadLine());
                }
                catch {
                    Console.WriteLine("recommence!");
                }
            }while(choix_rempli != 1 && choix_rempli != 2 && choix_rempli != 3);
            Console.Clear();
            if (choix_rempli == 1)
            {
                Console.WriteLine("choisissez une taille superieur à 4"); //choix de la taille
                int taille = 0;
                do
                {
                    try
                    {
                        taille = int.Parse(Console.ReadLine());
                    }
                    catch {
                        Console.Clear();
                        Console.WriteLine("recommence!");
                    }
                }//taille
                while(taille < 4);



                Console.WriteLine("quel niveau voulez vous?\n1- niveau 1 (pas d'energie et pas d'age)\n2- niveau 2 (age et energie pris en compte)");
                int choix = 0;//niveau
                do
                {
                    try
                    {
                        choix = int.Parse(Console.ReadLine());
                    }
                    catch {
                        Console.WriteLine("recommence!");
                    }
                }//niveau
                while(choix != 1 && choix != 2);
                int nombreDeGen = 0;
                Console.WriteLine("choisissez le nombre de gen");
                do
                {
                    try
                    {
                        nombreDeGen = int.Parse(Console.ReadLine());
                    }
                    catch {
                        Console.WriteLine("recommence!");
                    }
                }//nbgen
                while(nombreDeGen <= 0);
                Console.Clear();
                //niveau
                while (choix != 1 && choix != 2)
                {
                    ;
                }
                Grille grille = new Grille(taille);
                if (choix == 1)
                {
                    Vrainiveau1(grille, nombreDeGen - 1);
                }
                if (choix == 2)
                {
                    Vrainiveau2(grille, nombreDeGen - 1);
                }
            }
            if (choix_rempli == 2)
            {
                Console.WriteLine("choisissez une taille");
                int taille = 0;
                do
                {
                    try
                    {
                        taille = int.Parse(Console.ReadLine());
                    }
                    catch {
                        Console.WriteLine("recommence!");
                    }
                }while(taille <= 0);
                Console.WriteLine("choisisse un %");

                int pourcentage = 0;
                do
                {
                    try
                    {
                        pourcentage = int.Parse(Console.ReadLine());
                    }
                    catch {
                        Console.WriteLine("recommence!");
                    }
                }       while(pourcentage > 100);
                Grille grille = new Grille(taille, pourcentage);
                Console.WriteLine("quel niveau voulez vous?\n1- niveau 1 (pas d'energie et pas d'age)\n2- niveau 2 (age et energie pris en compte)");
                int choix = 0;//niveau
                do
                {
                    try
                    {
                        choix = int.Parse(Console.ReadLine());
                    }
                    catch {
                        Console.WriteLine("recommence!");
                    }
                }//niveau
                while(choix != 1 && choix != 2);
                int nombreDeGen = 0;
                Console.WriteLine("choisissez le nombre de gen");
                do
                {
                    try
                    {
                        nombreDeGen = int.Parse(Console.ReadLine());
                    }
                    catch {
                        Console.WriteLine("recommence!");
                    }
                }//nbgen
                while(nombreDeGen <= 0);

                //niveau
                while (choix != 1 && choix != 2)
                {
                    ;
                }
                if (choix == 1)
                {
                    Vrainiveau1(grille, nombreDeGen - 1);
                }
                if (choix == 2)
                {
                    Vrainiveau2(grille, nombreDeGen - 1);
                }
            }
            if (choix_rempli == 3)
            {
                Console.WriteLine("choisissez une taille");
                int taille = 0;
                do
                {
                    try
                    {
                        taille = int.Parse(Console.ReadLine());
                    }
                    catch {
                        Console.WriteLine("recommence!");
                    }
                }while(taille <= 0);

                Console.WriteLine("choisisse un %");
                int pourcentage = 0;
                do
                {
                    try
                    {
                        pourcentage = int.Parse(Console.ReadLine());
                    }
                    catch {
                        Console.WriteLine("recommence!");
                    }
                }       while(pourcentage > 100);

                Console.WriteLine("choisisse un age");
                int age = 0;
                do
                {
                    try
                    {
                        age = int.Parse(Console.ReadLine());
                    }
                    catch {
                        Console.WriteLine("recommence!");
                    }
                }       while(age <= 0);
                Console.WriteLine("choisisse une energie");
                int energie = 0;
                do
                {
                    try
                    {
                        energie = int.Parse(Console.ReadLine());
                    }
                    catch {
                        Console.WriteLine("recommence!");
                    }
                }       while(energie <= 0);
                int nombreDeGen = 0;
                Console.WriteLine("choisissez le nombre de gen");
                do
                {
                    try
                    {
                        nombreDeGen = int.Parse(Console.ReadLine());
                    }
                    catch {
                        Console.WriteLine("recommence!");
                    }
                }//nbgen
                while(nombreDeGen <= 0);



                Grille grille = new Grille(taille, pourcentage, "r", age, energie);

                Vrainiveau2(grille, nombreDeGen - 1);
            }
        }