コード例 #1
0
        private static string GeneraAddRel(ref NomiClass gen, bool lettere)
        {
            char carattere3 = RandomClass.RandomLetteraRelazione();

            if (lettere)
            {
                char carattere1 = RandomClass.RandomLettera();
                char carattere2 = RandomClass.RandomLettera();
                return("addrel \"" + carattere1 + "\" \"" + carattere2 + "\" \"" + carattere3 + "\"");
            }

            String nome1, nome2;
            int    n1, n2;
            Random rand = new Random();

            n1 = rand.Next(11);
            n2 = rand.Next(11);
            if (n1 <= 8)
            {
                nome1 = gen.GeneraNomeUsato();
            }
            else
            {
                nome1 = gen.NomeCasuale();
            }
            if (n2 <= 7)
            {
                nome2 = gen.GeneraNomeUsato();
            }
            else
            {
                nome2 = gen.NomeCasuale();
            }
            return("addrel " + nome1 + " " + nome2 + " \"" + carattere3 + "\"");
        }
コード例 #2
0
        private static string GeneraLinea(ref NomiClass gen, bool lettere)
        {
            int choice = RandomClass.rnd.Next(0, 100);

            if (choice >= 0 && choice <= 20)
            {
                return(GeneraAddEnt(ref gen, lettere));
            }
            if (choice > 20 && choice <= 60)
            {
                return(GeneraDelEnt(ref gen, lettere));
            }
            if (choice > 60 && choice <= 85)
            {
                return(GeneraAddRel(ref gen, lettere));
            }
            if (choice > 85 && choice <= 95)
            {
                return(GeneraDelRel(ref gen, lettere));
            }
            if (choice > 95 && choice <= 100)
            {
                return("report");
            }

            throw new Exception();
        }
コード例 #3
0
        private static string GeneraAddEnt(ref NomiClass gen, bool lettere)
        {
            if (lettere)
            {
                int lettera = RandomClass.rnd.Next(0, 26);
                lettera += 'a';
                char carattere = (char)lettera;
                return("addent \"" + carattere + "\"");
            }
            string nome = gen.GeneraNome();

            return("addent " + nome);
        }
コード例 #4
0
        private static void GeneraTest(int avg_lines, bool interagisciFinale, bool lettere)
        {
            NomiClass     genNomi = new NomiClass();
            List <string> L       = new List <string>();

            for (int i = 0; i < avg_lines; i++)
            {
                L.Add(GeneraLinea(ref genNomi, lettere));
            }
            L.Add("end");

            string output_path = DirectoryClass.GetOutputPath();

            File.WriteAllLines("i/" + output_path, L);
            var r = SolveClass.Solve("i/" + output_path, interagisciFinale);

            DirectoryClass.Save("o/" + output_path, r);
        }
コード例 #5
0
        private static string GeneraDelEnt(ref NomiClass gen, bool lettere)
        {
            if (lettere)
            {
                char carattere = RandomClass.RandomLettera();
                return("delent \"" + carattere + "\"");
            }

            string nome;
            Random rand = new Random();
            int    n    = rand.Next(11);

            if (n <= 5)
            {
                nome = gen.GeneraNomeUsato();
            }
            else
            {
                nome = gen.NomeCasuale();
            }
            gen.RimuoviDaUsati(nome);
            return("delent " + nome);
        }