Esempio n. 1
0
        public virtual float JeuHasard(PositionS p)
        {
            PositionS q = p.Clone();

            while (q.NbCoups1 > 0 && q.NbCoups0 > 0)
            {
                q.EffectuerCoup(gen.Next(0, q.NbCoups1), gen.Next(0, q.NbCoups0));
            }
            return(q.Eval);
        }
Esempio n. 2
0
        public NoeudS MeilleurFils()
        {
            if (fils[indiceMeilleurFils1, indiceMeilleurFils0] != null)
            {
                return(fils[indiceMeilleurFils1, indiceMeilleurFils0]);
            }
            PositionS q = p.Clone();

            q.EffectuerCoup(indiceMeilleurFils1, indiceMeilleurFils0);
            fils[indiceMeilleurFils1, indiceMeilleurFils0] = new NoeudS(this, q);
            return(fils[indiceMeilleurFils1, indiceMeilleurFils0]);
        }
Esempio n. 3
0
        public void Commencer(bool affichage = true)
        {
            j1.NouvellePartie();
            j0.NouvellePartie();
            do
            {
                if (affichage)
                {
                    pCourante.Affiche(); Console.WriteLine();
                }

                Task <int> t1 = Task.Run(() => j1.Jouer(pCourante.Clone(), true));
                Task <int> t0 = Task.Run(() => j0.Jouer(pCourante.Clone(), false));
                t1.Wait(); t0.Wait();
                pCourante.EffectuerCoup(t1.Result, t0.Result);

                //int rep1 = j1.Jouer(pCourante.Clone(), true);
                //int rep0 = j0.Jouer(pCourante.Clone(), false);
                //pCourante.EffectuerCoup(rep1, rep0);

                j1.Des(); j0.Des();
            } while (pCourante.NbCoups1 > 0 && pCourante.NbCoups0 > 0);
            r = pCourante.Eval;
            if (affichage)
            {
                pCourante.Affiche();
                int re = 0; if (r > 0)
                {
                    re = 1;
                }
                if (r < 0)
                {
                    re = -1;
                }
                switch (re)
                {
                case 1: Console.WriteLine("j1 {0} a gagné {1}.", j1, r); break;

                case -1: Console.WriteLine("j0 {0} a gagné {1}.", j0, -r); break;

                case 0: Console.WriteLine("Partie nulle."); break;
                }
            }
        }