public void Demarrage() { // Récupération des données des combobox var minMax = (minMaxBox.SelectedItem as ComboBoxItem).Tag.ToString(); var profondeur = (profondeurBox.SelectedItem as ComboBoxItem).Tag.ToString(); // Initialisation des données var game = new Jeu(); game.Ligne = 6; game.Colonne = 7; game.Statut = Statuts.EnCours; game.Profondeur = int.Parse(profondeur); game.Score = 100000; game.NbrPointsGagnant = 4; if(minMax != "MinMax") { game.EstAlphaBeta = true; } // Initialisation du jeu puissance4 = new Puissance4(game, new int?[game.Ligne, game.Colonne], 0); // Si que IA while (AffichageMessageFin(puissance4.VerifierJeu()){ JoueurMachineAlgo(); } }
private void JoueurMachineAlgo() { // on appelle l'algorithme minimax var retourIA = puissance4.DecisionIA(); // On a la colonne sélectionné pr l'IA var tupleLigneRetourIA = puissance4.Placer(retourIA); if (!tupleLigneRetourIA.Item1) { throw new Exception(); } var boutonCliquerIA = gridJeu.Children.Cast<UIElement>() .FirstOrDefault(e => Grid.GetRow(e) == tupleLigneRetourIA.Item2 && Grid.GetColumn(e) == retourIA) as Button; // On change le fond en rouge du bouton sélectionné par l'IA boutonCliquerIA.Background = Color.Red; if (AffichageMessageFin(puissance4.VerifierJeu())) { return; } }