Exemple #1
0
        private static int max(Plateau plateau)
        {
            if (plateau.IsFull())
            {
                return eval(plateau);
            }
            int coef = -10000;
                 int tmp =0;
            foreach (var c in plateau.Cases)
            {
                if (c.motif == Motif.Vide)
                {
                    c.motif = plateau.motifMax;
                    Console.WriteLine(plateau.ToString());
                    tmp = min(plateau);

                    if (tmp > coef)
                    {
                        coef = tmp;
                    }
                    c.motif = Motif.Vide;
                }
            }
            return coef;
        }
Exemple #2
0
 private static int eval(Plateau plateau)
 {
     var nbPions = plateau.Cases.Where(x => x.motif != Motif.Vide).Count();
     string resultat = "égalité";
     if (plateau.MotifMaxGagne())
     {
         resultat = plateau.motifMax + " gagne";
         Console.WriteLine(resultat);
         return 1000 - nbPions;
     }
     if (plateau.MotifMinGagne())
     {
         resultat = plateau.motifMin + " gagne";
         Console.WriteLine(resultat);
         return -1000 + nbPions;
     }
     Console.WriteLine(resultat);
     return 0;
 }
Exemple #3
0
        public string GetValue(string p, int? dernierCoupJoue = null)
        {
            Plateau plateau = new Plateau(p, dernierCoupJoue);
            Console.WriteLine(plateau.ToString());

            int max = -1000;
            int tmp = 0;
            int position = 1;

            if (plateau.Cases.Where(x => x.motif == Motif.Vide).Count() == 9)
            {
                return "1";
            }
            if (plateau.Cases.Where(x => x.motif == plateau.motifMin).Count() == 1 && plateau.Cases.Where(x => x.motif == Motif.Vide).Count() == 8)
            {
                var c = plateau.Cases.Where(x => x.motif == plateau.motifMin).First();
                return c.Position==5?"1":"5";
            }

            foreach (var c in plateau.Cases)
            {
                if (c.motif == Motif.Vide)
                {
                    c.motif = plateau.motifMax;
                    Console.WriteLine(plateau.ToString());
                    tmp = min(plateau);
                    if (tmp > max)
                    {
                        max = tmp;
                position = c.Position;
                    }
                    c.motif = Motif.Vide;
                Console.WriteLine("Position {0} : coef {1}", position.ToString(),max);
                }
            }
            return position.ToString() ;
        }
Exemple #4
0
 private string debut(Plateau plateau)
 {
     throw new NotImplementedException();
 }