示例#1
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() ;
        }
示例#2
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;
        }