Exemplo n.º 1
0
        public override int Jouer(PositionS p, bool asj1)
        {
            sw.Restart();
            Func <int, float, float> phi = (C, W) => (a + W) / (a + C);

            racine = new NoeudS(null, p);
            iter   = 0;
            while (sw.ElapsedMilliseconds < temps)
            {
                NoeudS no = racine;

                do // Sélection
                {
                    no.CalculMeilleurFils(phi, gen);
                    no = no.MeilleurFils();
                } while (no.cross > 0 && no.fils.Length > 0);

                float re = JeuHasard(no.p); // Simulation

                while (no != null)          // Rétropropagation
                {
                    no.cross += 1;
                    no.win   += re;
                    no        = no.pere;
                }
                iter++;
            }
            racine.CalculMeilleurFils(phi, gen);
            int rep = (asj1) ? racine.indiceMeilleurFils1 : racine.indiceMeilleurFils0;

            return(rep);
        }
Exemplo 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]);
        }
Exemplo n.º 3
0
 public NoeudS(NoeudS pere, PositionS p)
 {
     this.pere = pere;
     this.p    = p;
     fils      = new NoeudS[this.p.NbCoups1, this.p.NbCoups0];
 }
Exemplo n.º 4
0
 public override void NouvellePartie()
 {
     racine = null;
 }