List <List <float> > SampleExpressiveRangeRandomly(int totalAttempts, Danesh gen) { float progressBar = 0f; EditorUtility.DisplayProgressBar("Computing Randomised Expressive Range Histogram", "Working...", progressBar); List <List <float> > res = new List <List <float> >(); List <GeneratorMetric> metrics = danesh.GetMetricsForActiveGenerator(); /* * Current: * eraSample[metric1][metric2] = object[,] of samples representing the histogram * Lot of data duplication here, not the most efficient way to do it */ eraSamples = new List <List <GeneratorSample[, ]> >(); for (int i = 0; i < metrics.Count; i++) { List <GeneratorSample[, ]> secondmetric = new List <GeneratorSample[, ]>(); for (int j = 0; j < metrics.Count; j++) { GeneratorSample[,] sampleH = new GeneratorSample[100, 100]; secondmetric.Add(sampleH); } eraSamples.Add(secondmetric); } List <GeneratorParameter> genParams = gen.GetParametersForActiveGenerator(); for (int att = 0; att < totalAttempts; att++) { //Hold this so we can find this version later object[] ps = new object[genParams.Count]; //Randomly parameterise the generator for (int i = 0; i < genParams.Count; i++) { GeneratorParameter p = genParams[i]; p.RandomiseValue(); ps[i] = p.GetValue(); } object map = danesh.GenerateContent(); List <float> nums = new List <float>(); for (int i = 0; i < metrics.Count; i++) { float score = (float)danesh.GetMetric(i, new object[] { map }); nums.Add(score); } //Update the samples list for (int i = 0; i < nums.Count; i++) { int index1 = (int)Mathf.Floor(nums[i] * 100f); if (index1 < 0) { index1 = 0; } if (index1 > 99) { index1 = 99; } for (int j = 0; j < nums.Count; j++) { int index2 = (int)Mathf.Floor(nums[j] * 100f); if (index2 < 0) { index2 = 0; } if (index2 > 99) { index2 = 99; } eraSamples[i][j][index1, index2] = new GeneratorSample(map, ps); } } res.Add(nums); EditorUtility.DisplayProgressBar("Computing Randomised Expressive Range Histogram", "Evaluating random expressive range... " + (100 * (float)att / (float)totalAttempts).ToString("F0") + " percent complete", (float)att / (float)totalAttempts); } EditorUtility.ClearProgressBar(); return(res); }
List <List <float> > SampleExpressiveRange(int totalAttempts, Danesh gen) { float progressBar = 0f; EditorUtility.DisplayProgressBar("Computing Expressive Range", "Working...", progressBar); List <List <float> > res = new List <List <float> >(); List <GeneratorMetric> metrics = danesh.GetMetricsForActiveGenerator(); List <GeneratorParameter> genParams = gen.GetParametersForActiveGenerator(); //Hold this so we can find this version later object[] ps = new object[genParams.Count]; for (int i = 0; i < genParams.Count; i++) { ps[i] = genParams[i].currentValue; } eraSamples = new List <List <GeneratorSample[, ]> >(); for (int i = 0; i < metrics.Count; i++) { List <GeneratorSample[, ]> secondmetric = new List <GeneratorSample[, ]>(); for (int j = 0; j < metrics.Count; j++) { GeneratorSample[,] sampleH = new GeneratorSample[100, 100]; secondmetric.Add(sampleH); } eraSamples.Add(secondmetric); } for (int att = 0; att < totalAttempts; att++) { object map = danesh.GenerateContent(); List <float> nums = new List <float>(); for (int i = 0; i < metrics.Count; i++) { float score = 0f; try{ score = (float)metrics[i].method.Invoke(null, new object[] { map }); } catch { } nums.Add(score); } res.Add(nums); //Update the samples list for (int i = 0; i < nums.Count; i++) { int index1 = (int)Mathf.Floor(nums[i] * 100f); if (index1 < 0) { index1 = 0; } if (index1 > 99) { index1 = 99; } for (int j = 0; j < nums.Count; j++) { int index2 = (int)Mathf.Floor(nums[j] * 100f); if (index2 < 0) { index2 = 0; } if (index2 > 99) { index2 = 99; } eraSamples[i][j][index1, index2] = new GeneratorSample(map, ps); } } EditorUtility.DisplayProgressBar("Computing Expressive Range", "Evaluating expressive range... " + (100 * (float)att / (float)totalAttempts).ToString("F0") + " percent complete", (float)att / (float)totalAttempts); } EditorUtility.ClearProgressBar(); return(res); }