public DefaultEvolutionJob(DnaDrawing drawing, JobInfo info) { this.info = info; if (drawing == null) drawing = GetNewInitializedDrawing(info); lock (drawing) { currentDrawing = drawing.Clone(); } currentErrorLevel = FitnessCalculator.GetDrawingFitness(currentDrawing, info.SourceImage); }
private void StartEvolution() { var sourceImage = new SourceImage { Pixels = SetupSourceColorMatrix(picPattern.Image as Bitmap), Width = picPattern.Width, Height = picPattern.Height }; var info = new JobInfo { Settings = Project.Settings, SourceImage = sourceImage, }; //IEvolutionJob job = new LayeredEvolutionJob(sourceImage, 4); //DefaultEvolutionJob job = new DefaultEvolutionJob(sourceImage, currentDrawing); //IEvolutionJob job = new DefaultEvolutionJob(info); IEvolutionJob job = new ClusteredEvolutionJob(info); while (Project.IsRunning) { double newErrorLevel = job.GetNextErrorLevel(); var defJob = job as DefaultEvolutionJob; if (defJob != null) Project.Generations += defJob.Generations; Project.Mutations++; if (newErrorLevel <= Project.ErrorLevel) { Project.Selected++; if (newErrorLevel < Project.ErrorLevel) Project.Positive++; else Project.Neutral++; DnaDrawing newDrawing = job.GetDrawing(); if (currentDrawing == null) // to make always lockable... currentDrawing = new DnaDrawing(); lock (currentDrawing) { currentDrawing = newDrawing; Project.Drawing = currentDrawing.Clone(); } Project.ErrorLevel = newErrorLevel; SaveAnimationImage(newDrawing); } } }
private void OpenDNA() { Stop(); DnaDrawing drawing = Serializer.DeserializeDnaDrawing(FileUtil.GetOpenFileName(FileUtil.DnaExtension)); if (drawing != null) { if (currentDrawing == null) currentDrawing = new DnaDrawing(); lock (currentDrawing) { currentDrawing = drawing; guiDrawing = currentDrawing.Clone(); Project.Drawing = currentDrawing; } ResetProjectLevels(); RepaintCanvas(); } }
private void OpenProject() { Stop(); string fileName = FileUtil.GetOpenFileName(FileUtil.ProjectExtension); DnaProject project = Serializer.DeserializeDnaProject(fileName); if (project != null) { Project = project; if (!string.IsNullOrEmpty(Project.ImagePath)) OpenImage(Project.ImagePath); if (Project.Drawing != null) { if (currentDrawing == null) currentDrawing = new DnaDrawing(); lock (currentDrawing) { currentDrawing = Project.Drawing; guiDrawing = currentDrawing.Clone(); } } ActivateProjectSettings(); ResetProjectLevels(); RepaintCanvas(); projectFileName = fileName; } SetTitleBar(); }
private void OpenDNA() { Stop(); DnaDrawing drawing = Serializer.DeserializeDnaDrawing(FileUtil.GetOpenFileName(FileUtil.DnaExtension)); if (drawing != null) { if (currentDrawing == null) currentDrawing = GetNewInitializedDrawing(); lock (currentDrawing) { currentDrawing = drawing; guiDrawing = currentDrawing.Clone(); } pnlCanvas.Invalidate(); lastRepaint = DateTime.Now; } }