Пример #1
0
        private void Resolution_alternative()
        {
            string solution;

            solution = Calcul.Cherche(_listeNombre, _nombreatrouver);
            if (solution != null)
            {
                plusProche = _nombreatrouver;
                ValidationOperation(solution);
                _loading = false;
            }
            else
            {
                comptebon = false;
                solution  = Calcul.Cherche(_listeNombre, _nombreatrouver - 1);
                if (solution != null)
                {
                    plusProche = _nombreatrouver - 1;
                    ValidationOperation(solution);
                    _loading = false;
                }
                else
                {
                    solution = Calcul.Cherche(_listeNombre, _nombreatrouver + 1);
                    if (solution != null)
                    {
                        plusProche = _nombreatrouver + 1;
                        ValidationOperation(solution);
                        _loading = false;
                    }
                    else
                    {
                        solution = Calcul.Cherche(_listeNombre, _nombreatrouver + 2);
                        if (solution != null)
                        {
                            plusProche = _nombreatrouver + 2;
                            ValidationOperation(solution);
                            _loading = false;
                        }
                        else
                        {
                            solution = Calcul.Cherche(_listeNombre, _nombreatrouver - 2);
                            if (solution != null)
                            {
                                plusProche = _nombreatrouver - 2;
                                ValidationOperation(solution);
                                _loading = false;
                            }

                            else
                            {
                                pasdesolution = true;
                                _loading      = false;
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        private void IA_Initialize()
        {
            int    diff_int    = save.ListeSave.Difficulte;
            string Diff_string = "";

            switch (diff_int)
            {
            case 1: Diff_string = "Blanc"; break;

            case 2: Diff_string = "Vert"; break;

            case 3: Diff_string = "Bleu"; break;

            case 4: Diff_string = "Jaune"; break;

            case 5: Diff_string = "Orange"; break;
            }

            int bonus = 0;

            string[] pourcentageArray;
            if (!comptebon)
            {
                bonus++;
            }
            foreach (var caca in difficulte.ListeDifficulte)
            {
                if (caca.Difficulte == Diff_string)
                {
                    pourcentageArray = caca.ListePourcentageChiffres.Split(new char[] { ' ' });
                    int hazard = random.Next(1, 101);
                    int somme  = 0;
                    int i      = 1;
                    foreach (string foutre in pourcentageArray)
                    {
                        somme += int.Parse(foutre);
                        if (somme > hazard)
                        {
                            break;
                        }
                        else
                        {
                            i++;
                        }
                    }
                    int Nombre_a_chercher = i + bonus;
                    if (i == 7)
                    {
                        _resultatAdversaire = 0;
                    }
                    else
                    {
                        string solution;
                        solution = Calcul.Cherche(_listeNombre, _nombreatrouver - Nombre_a_chercher);
                        if (solution != null)
                        {
                            _resultatAdversaire = _nombreatrouver - Nombre_a_chercher;
                        }
                        else
                        {
                            solution = Calcul.Cherche(_listeNombre, _nombreatrouver + Nombre_a_chercher);
                            if (solution != null)
                            {
                                _resultatAdversaire = _nombreatrouver + Nombre_a_chercher;
                            }
                            else
                            {
                                solution = Calcul.Cherche(_listeNombre, _nombreatrouver + Nombre_a_chercher + 1);
                                if (solution != null)
                                {
                                    _resultatAdversaire = _nombreatrouver + Nombre_a_chercher + 1;
                                }
                                else
                                {
                                    solution = Calcul.Cherche(_listeNombre, _nombreatrouver - Nombre_a_chercher - 1);
                                    if (solution != null)
                                    {
                                        _resultatAdversaire = _nombreatrouver - Nombre_a_chercher - 1;
                                    }
                                    else
                                    {
                                        solution = Calcul.Cherche(_listeNombre, _nombreatrouver + Nombre_a_chercher + 2);
                                        if (solution != null)
                                        {
                                            _resultatAdversaire = _nombreatrouver + Nombre_a_chercher + 2;
                                        }
                                        else
                                        {
                                            solution = Calcul.Cherche(_listeNombre, _nombreatrouver - Nombre_a_chercher - 2);
                                            if (solution != null)
                                            {
                                                _resultatAdversaire = _nombreatrouver - Nombre_a_chercher - 2;
                                            }
                                            else
                                            {
                                                _resultatAdversaire = _resultatjoueur;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }