Esempio n. 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            reussite = 3;

            numinitial = Convert.ToInt32(textBox1.Text);
            numfinal   = Convert.ToInt32(textBox2.Text);
            SearchTree g  = new SearchTree();
            Node2      N0 = new Node2();

            N0.numero = numinitial;
            List <GenericNode> solution = g.RechercheSolutionAEtoile(N0);


            g.GetSearchTree(treeView1);

            Correcteur c = new Correcteur();


            int resultat = c.CorrigeOuverts(L_TextBoxs_Ouverts, g.ouverts, alphabet);

            AfficheCorrectionOuverts(resultat);
            if (resultat != -1)
            {
                reussite = 0;
            }


            resultat = c.CorrigeFermes(L_TextBoxs_Fermes, g.fermes, alphabet);
            AfficheCorrectionFermes(resultat);
            if (resultat != -1)
            {
                reussite = 0;
            }
            //else {Bscore.Show() ; }
        }
Esempio n. 2
0
        private void Initialisation()
        {
            matrice = new double[nbnodes, nbnodes];
            for (int i = 0; i < nbnodes; i++)
            {
                for (int j = 0; j < nbnodes; j++)
                {
                    matrice[i, j] = -1;
                }
            }

            matrice[0, 1] = 3; matrice[1, 0] = 3;
            matrice[0, 2] = 5; matrice[2, 0] = 5;
            matrice[0, 3] = 7; matrice[3, 0] = 7;
            matrice[1, 4] = 8; matrice[4, 1] = 8;
            matrice[2, 4] = 3; matrice[4, 2] = 3;
            matrice[4, 5] = 7; matrice[5, 4] = 7;
            matrice[5, 6] = 4; matrice[6, 5] = 4;

            numinitial = Convert.ToInt32(textBox1.Text);
            numfinal   = Convert.ToInt32(textBox2.Text);
            Node2 N0 = new Node2();

            N0.numero = numinitial;

            List <GenericNode> solution = g.RechercheSolutionAEtoile(N0);

            Node2 N1 = N0;

            //affichage
            for (int i = 1; i < solution.Count; i++)
            {
                Node2 N2 = (Node2)solution[i];
                listBox1.Items.Add(Convert.ToString(N1.numero)
                                   + "--->" + Convert.ToString(N2.numero)
                                   + "   : " + Convert.ToString(matrice[N1.numero, N2.numero]));
                N1 = N2;
            }
        }
Esempio n. 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            numinitial = Convert.ToInt32(textBox1.Text);
            numfinal   = Convert.ToInt32(textBox2.Text);
            SearchTree g  = new SearchTree();
            Node2      N0 = new Node2();

            N0.numero = numinitial;
            List <GenericNode> solution = g.RechercheSolutionAEtoile(N0);

            Node2 N1 = N0;

            for (int i = 1; i < solution.Count; i++)
            {
                Node2 N2 = (Node2)solution[i];
                listBox1.Items.Add(Convert.ToString(N1.numero)
                                   + "--->" + Convert.ToString(N2.numero)
                                   + "   : " + Convert.ToString(matrice[N1.numero, N2.numero]));
                N1 = N2;
            }

            g.GetSearchTree(treeView1);
        }
        //Le bouton A* lance l'agorithme de recherche avant d'afficher les paramètres clés dans le form
        private void button3_Click(object sender, EventArgs e)
        {
            //paramètres
            Node Point_Initial = new Node(Convert.ToDouble(X_init.Text), Convert.ToDouble(Y_init.Text), Convert.ToChar(cbChoixVent.SelectedItem.ToString()));
            Node Point_final   = new Node(Convert.ToDouble(X_final.Text), Convert.ToDouble(Y_final.Text), Convert.ToChar(cbChoixVent.SelectedItem.ToString()));

            Node.Pf_x           = Convert.ToDouble(X_final.Text);
            Node.Pf_y           = Convert.ToDouble(Y_final.Text);
            Node.distance_Noeud = Convert.ToDouble(tBDistanceNoeud.Text);
            Node.Zone_voisinage = Convert.ToDouble(tBZoneVoisin.Text);

            listBox1.Items.Add("( " + Convert.ToString(Point_Initial.P_x) + ", " + Convert.ToString(Point_Initial.P_y) + ")");
            Point_Initial.cas = Convert.ToChar(cbChoixVent.SelectedItem.ToString());
            SearchTree g = new SearchTree();

            //Lancement de la recherche
            Point_Initial.GenericCas = Point_Initial.cas;
            List <GenericNode> solution = g.RechercheSolutionAEtoile(Point_Initial);

            MessageBox.Show(Convert.ToString(solution.Count));
            Node N1 = Point_Initial;

            for (int i = 0; i < solution.Count; i++)
            {
                Node N2 = (Node)solution[i];
                soluce.Add(N2);
                listBox1.Items.Add("( " + N2.P_x + ", " + N2.P_y + ")");
                N1 = N2;
                if (i == solution.Count - 1)
                {
                    tpsNavigation.Text = Convert.ToString(solution[i].GetGCost());
                }
            }
            g.GetSearchTree(treeView1);
            tBNfermes.Text  = Convert.ToString(g.L_Fermes.Count);
            tBNouverts.Text = Convert.ToString(g.L_Ouverts.Count);
        }