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() ; } }
private void buttonShowTree_Click(object sender, EventArgs e) { if (matrice != null) { isGraphInMemory.Visible = false; isGraphInMemory2.Visible = false; var g = new SearchTree(); Algorithme_AEtoile(g); Node2 N0 = new Node2(); N0.numero = numinitial; var l = g.RechercheSolutionAEtoile2(N0); Node2 NEnd = (Node2)l.Last(); var lastFerme = g.L_Fermes; lastFerme.Add(NEnd); var drawForm = new TreeDrawForm(lastFerme); drawForm.ShowDialog(); reussite2 = drawForm.GetReussite(); groupBoxCor2Part.Visible = true; buttonQuitter.Visible = true; } else { isGraphInMemory.Visible = true; isGraphInMemory2.Visible = true; } }
private void AffichageHistoIA(SearchTree g) { string nouveauOuvert = ""; string nouveauFerme = ""; foreach (List <GenericNode> listeN in g.historiqueIAFermes) // état par état { nouveauFerme = ""; foreach (GenericNode n in listeN) // noeud de chaque état { nouveauFerme += Convert.ToString(((Node2)n).numero) + ", "; } listBoxShowFermeIA.Items.Add(nouveauFerme); } g.historiqueIAOuverts.RemoveAt(0); foreach (List <GenericNode> listeN in g.historiqueIAOuverts) { nouveauOuvert = ""; foreach (GenericNode n in listeN) { nouveauOuvert += Convert.ToString(((Node2)n).numero) + ", "; } listBoxShowOuvertIA.Items.Add(nouveauOuvert); } }
private bool Algorithme_AEtoile(SearchTree g) { Node2 N0 = new Node2(); N0.numero = numinitial; List <GenericNode> solution = g.RechercheSolutionAEtoile2(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(treeViewCorrection); bool reussite = false; reussite = (Correction(historiqueUtiFerme, g.historiqueIAFermes) && (Correction(historiqueUtiOuvert, g.historiqueIAOuverts))); return(reussite); }
public void btn_Valider_Click(object sender, EventArgs e) { if (matrice != null) { if ((textBoxOuverts.Text == "") && (textBoxFermes.Text != "")) { this.AjoutOuvertFermetUti(textBoxFermes.Text, false); SearchTree g = new SearchTree(); bool reussite = Algorithme_AEtoile(g); if (reussite == true) { this.labelShowCorrectOrNot.Text = "Bonne réponse"; this.labelShowCorrectOrNot.ForeColor = Color.Green; reussite1 = true; } else { this.labelShowCorrectOrNot.Text = "Mauvaise réponse"; this.labelShowCorrectOrNot.ForeColor = Color.Red; reussite1 = false; } this.labelShowCorrectOrNot.Visible = true; groupBoxCor1Part.Visible = true; AffichageHistoIA(g); } else if ((textBoxOuverts.Text != "") && (textBoxFermes.Text != "")) { if ((textBoxOuverts.Text != (-1).ToString()) && (textBoxFermes.Text != (-1).ToString())) { this.AjoutOuvertFermetUti(textBoxFermes.Text, false); this.AjoutOuvertFermetUti(textBoxOuverts.Text, true); } } } else { isGraphInMemory2.Visible = true; } }
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); }
private void verificationFermes(SearchTree s) { foreach (GenericNode noeud in s.L_Fermes) { } }
private void verificationOuverts(SearchTree s) { foreach (GenericNode noeud in s.L_Ouverts) { } }