예제 #1
0
        private void WorkerThreadStart()
        {
            Initialize();

            while (isRunning)
            {
                //assign current work data to a tmp var, so that we use the same data through the entire itteration
                //even if data is changed by the main thread, nothing will break or go wrong.
                WorkerData tmpData = data;


                if (tmpData.hasNewParent)
                {
                    Tools.InitRandom(tmpData.randomSeed);
                    tmpData.hasNewParent = false;
                }


                DnaDrawing newDrawing = GetMutatedSeedSyncedDrawing();

                double newErrorLevel = FitnessCalculator.GetDrawingFitness(newDrawing, info.SourceImage,
                                                                           partitionY, partitionHeight);

                var result = new DnaPartitionResult
                {
                    Drawing    = newDrawing,
                    ErrorLevel = newErrorLevel,
                };


                tmpData.workerTail.Enqueue(result);
            }
        }
예제 #2
0
 private void Initialize()
 {
     Tools.InitRandom(data.randomSeed);
     parentDrawing = new DnaDrawing
     {
         Polygons = new List <DnaPolygon>(),
     };
 }