public override int Jouer(Position p) { sw.Restart(); Func <int, int, float> phi = (W, C) => (a + W) / (b + C); racine = new NoeudP(null, p, this.N); if (racine == null) { racine = new NoeudP(null, p, this.N); } else { racine = racine.MeilleurFils(0); for (int i = 0; i < racine.p.NbCoups; i++) { if ((racine.fils[i] != null) && (racine.fils[i].p.Equals(p))) { racine = racine.fils[i]; break; } } } int iter = 0; while (sw.ElapsedMilliseconds < temps) { this.TaskList = new List <Task>(); NoeudP no = racine; for (int i = 0; i < this.N; i++) { int j = i; this.TaskList.Add(Task.Run(() => Calcul(no, phi, j))); iter++; } Task.WaitAll(this.TaskList.ToArray()); } Console.WriteLine("{0} itérations", iter); Console.WriteLine(racine); racine.CalculMeilleurFils(phi); return(racine.indiceMeilleurFils[0]); }
public void Calcul(NoeudP no, Func <int, int, float> phi, int i) { do // Sélection { no.CalculMeilleurFils(phi); no = no.MeilleurFils(i); } while (no.cross[i] > 0 && no.fils.Length > 0); re[i] = JeuHasard(no.p, i); // Simulation while (no != null) // Rétropropagation { no.cross[i] += 2; no.win[i] += re[i]; no = no.pere; } Console.WriteLine("test"); }