/// <summary> /// /// </summary> private void Update() { if (_pause == false) { //check if stack is finished building //if build not complete, leave function if (_model.BuildComplete == false) { return; } //if stack building is complete, get fitness / update if (_model.BuildComplete == true) { //calculate fitness _analyser.Fitness(); //add stack to current generation _currentStack.SetName("GEN " + generations + "_STACK " + _curCount); _currentStack.UpdateDataText(); //updates the datatext //add the stack to the generation AddStackToGeneration(_currentStack); _curCount++; //if count == popsize recalculate the mating pool if (_curCount == _genSize) { //add generation to the population history AddGenToPopulation(_currentGenerationData); //run natural selection to generate breeding pool - threshold value: include best performers above threshhold value (between 0,1)) UpdateMatingPool(0.5f); SerializeData(_currentGenerationData); //reset current population array _currentGenerationData = new CellStackData[_genSize]; //reset popcounter _curCount = 0; generations++; } //breed new dna from mating pool IDNAI childdna = Breed(); //reset the stack and insert new dna _currentStack.Restore(); _currentStack.SetDNA(childdna); _model.Stack = _currentStack; //ONLY IF USING GENES FOR PARTIAL IMAGE SEEDS - synthesize 4 images from child genes - don't use this if you dont have genes for image textures if (_SeedFromGenes == true) { Texture2D texture1 = _seeds[childdna.GetGene(0)]; Texture2D texture2 = _seeds[childdna.GetGene(1)]; Texture2D texture3 = _seeds[childdna.GetGene(2)]; Texture2D texture4 = _seeds[childdna.GetGene(3)]; Texture2D combined = ImageSynthesizer.CombineFour(texture1, texture2, texture3, texture4, _currentStack.RowCount, _currentStack.ColumnCount); //place the synthesized image into the stack _currentStack.SetSeed(combined); //resets/initializes the model using the synthesized image _model.ResetModel(combined); _analyser.ResetAnalysis(); } else { //resets/initializes the model using original seedimage _model.ResetModel(); _analyser.ResetAnalysis(); } } } }