Exemple #1
0
 private void BTN_Continuer_J2_Click(object sender, EventArgs e)
 {
     Jouer(2);
     J2.CalculerStat(paquet, CompteurCarte);
     J1.CalculerStat(paquet, CompteurCarte);
     J1.AIJoueEncore();
     if (J1.JoueEncore() && J1.GetCpuLevel() > 0)
     {
         Jouer(1);
     }
     else if (J1.GetCpuLevel() > 0 && !J1.JoueEncore())
     {
         ButtonRefresh();
     }
     CheckFinPartie();
 }
Exemple #2
0
 private void BTN_Commencer_Click(object sender, EventArgs e)
 {
     while (CompteurCarte < 4)
     {
         if (A_Qui_Le_Tour == 1)
         {
             AfficherUneCarte(CompteurCarte, J1);
             J1.CalculerStat(paquet, CompteurCarte);
             LB_J1_Stats.Text = J1.GetStat().ToString() + "%";
             A_Qui_Le_Tour    = 2;
         }
         else
         {
             AfficherUneCarte(CompteurCarte, J2);
             J2.CalculerStat(paquet, CompteurCarte);
             LB_J2_Stats.Text = J2.GetStat().ToString() + "%";
             A_Qui_Le_Tour    = 1;
         }
         CompteurCarte++;
     }
     BTN_Commencer.Visible = false;
     ButtonRefresh();
     CheckFinPartie();
     if (J1.GetCpuLevel() > 0 && J2.GetCpuLevel() > 0)
     {
         while (J1.JoueEncore() || J2.JoueEncore())
         {
             JouerAi();
         }
     }
     else if (J1.GetCpuLevel() > 0)
     {
         J1.CalculerStat(paquet, CompteurCarte);
         LB_J1_Stats.Text = J1.GetStat().ToString() + "%";
         J1.AIJoueEncore();
         Jouer(1);
         J1.CalculerStat(paquet, CompteurCarte);
         LB_J1_Stats.Text = J1.GetStat().ToString() + "%";
     }
 }
Exemple #3
0
        //CODE POUR LES TEST OPTIMAL ICI
        // |
        // V
        private void AutomaticAiLogic()
        {
            //on clear les resultat des test précédents
            string resultat = string.Empty;

            ScoreJ1.Clear();
            ScoreJ2.Clear();
            ScoreNull.Clear();
            for (int q = 0; q < 3; q++)
            {
                for (int i = POURCENTSTART; i <= POURCENTSTOP; i += 5) //pourcentage en bond de 5%
                {
                    x           = 0;
                    pourcentage = i;
                    ScoreJ1.Add(0);
                    ScoreJ2.Add(0);
                    ScoreNull.Add(0);
                    for (int j = 0; j < 100000 /*100 000 partie*/; j++)
                    {
                        for (int k = 0; k < 3; k++)//Choisit contre qui il joue
                        {
                            finFinal = false;
                            J1       = new Joueur(i, true, "J1");//Ai avec le pourcentage choisit

                            //Choisit contre qui il joue
                            if (k == 1 - 1)
                            {
                                J2 = new Joueur(50, true, "J2");
                            }
                            else if (k == 2 - 1)
                            {
                                J2 = new Joueur(65, true, "J2");
                            }
                            else if (k == 3 - 1)
                            {
                                J2 = new Joueur(80, true, "J2");
                            }
                            try
                            {
                                //Load et mélange le paket de carte
                                LoadCarte();
                                MixCards();
                            }
                            catch (Exception es)
                            {
                                MessageBox.Show(es.Message.ToString());
                                this.Close();
                            }

                            //début de partie
                            BTN_Commencer.Visible = false;
                            while (CompteurCarte < 4)
                            {
                                if (A_Qui_Le_Tour == 1)
                                {
                                    AfficherUneCarte(CompteurCarte, J1);
                                    J1.CalculerStat(paquet, CompteurCarte);
                                    A_Qui_Le_Tour = 2;
                                }
                                else
                                {
                                    AfficherUneCarte(CompteurCarte, J2);
                                    J2.CalculerStat(paquet, CompteurCarte);
                                    A_Qui_Le_Tour = 1;
                                }
                                CompteurCarte++;
                            }
                            ButtonRefresh();
                            CheckFinPartie();
                            if (J1.GetCpuLevel() > 0 && J2.GetCpuLevel() > 0)
                            {
                                //on joue jusqua une défaite
                                while (J1.JoueEncore() || J2.JoueEncore())
                                {
                                    JouerAi();
                                }
                            }
                            ButtonRefresh();
                            CheckFinPartie();
                        }
                    }
                    //on imprime les résultat dans une string
                    resultat += "[" + pourcentage.ToString() + "] " + ScoreJ1[x].ToString() + " J1 " + ScoreJ2[x].ToString() + " J2 " + ScoreNull[x].ToString() + " Null \r\n";
                    x++;
                }
                //on imprime une séparation dans la string
                resultat += "\r\n***\r\n";
            }
            //on imprime les résultat dans un textbox
            textBox1.Text         = resultat;
            BTN_Commencer.Visible = true;
            MessageBox.Show("Fini");//Fini
        }