public void NextGenClick(object sender, RoutedEventArgs routedEventArgs) { Individu[] newPop = new Individu[Population.MAXINDIVIDUS]; for (int i = 0; i < Population.MAXINDIVIDUS; i++) { int rnd = MidiComposer.GetRandom(0, 100); Individu newInd; if (rnd < Population.CROSSOVER) { Individu parent1 = SelectParent(); Individu parent2 = SelectParent(); newInd = new Individu(parent1, parent2); } else { Individu parent = SelectParent(); newInd = new Individu(parent); } newInd.Mutate(); newPop[i] = newInd; } Generation mg = new Generation(newPop); Survival(); Gens.Add(mg); //populations[nbPopulation] = new Population(nbPopulation + 1, newPop); }
// reset a nouvelle numGEn * 10 public Individu(Individu parent) { //TODO for (int i = 0; i < NBNOTES; i++) _notes[i] = parent._notes[i]; init(); }
// reset a nouvelle numGEn * 10 public Individu(Individu parent) { //TODO for (int i = 0; i < NBNOTES; i++) { _notes[i] = parent._notes[i]; } init(); }
public void CreateClick(object sender, RoutedEventArgs routedEventArgs) { Individu[] individus = new Individu[Population.MAXINDIVIDUS]; for (int i = 0; i < Population.MAXINDIVIDUS; i++) individus[i] = new Individu(); Generation gen = new Generation(individus); Gens.Add(gen); }
public Individu(Individu papa, Individu maman) { int rnd = MidiComposer.GetRandom(0, NBNOTES); for (int i = 0; i < NBNOTES; i++) { if (i < rnd) _notes[i] = papa._notes[i]; else _notes[i] = maman._notes[i]; } init(); }
public Individu(Individu papa, Individu maman) { int rnd = MidiComposer.GetRandom(0, NBNOTES); for (int i = 0; i < NBNOTES; i++) { if (i < rnd) { _notes[i] = papa._notes[i]; } else { _notes[i] = maman._notes[i]; } } init(); }
private static void Save(Individu selected) { FolderBrowserDialog dialog = new FolderBrowserDialog(); DialogResult result = dialog.ShowDialog(); string path = dialog.SelectedPath; string filename = selected.MidiFileName; try { MidiComposer mc = new MidiComposer(); if (!File.Exists(filename)) mc.CreateAndPlayMusic(selected.Notes, selected.MidiFileName, false); File.Copy(filename, path + "\\" + filename); //SaveButton.IsEnabled = true; } catch (Exception exception) { Debug.WriteLine("Erreur: " + exception.Message); } }