private void Assess(double[] outputlayer, int index) { outputlayer = ConvertFromBinaryToDouble(outputlayer); double[] attemptstats = new double[32]; double[] overallstats = new double[32]; //Add to buffer cb.Create(new CircleBufferEntry() { PrivateKey = dataSet[index].PrivateKey, PrivateKeyAttempt = outputlayer }); //Calculate stats for current attempt for (int i = 0; i < 32; i++) { if ((int)outputlayer[i] == (int)dataSet[index].PrivateKey[i]) { attemptstats[i]++; } } //Check if there is any byte match between output and private key bool match = false; for (int i = 0; i < 32; i++) { if (attemptstats[i] > 0) { match = true; } } //if there is a match then we are justified in broader assessment if (match) { //Calculate stats since last population crash CircleBufferEntry[] cbes = cb.Read(); for (int i = 0; i < cbes.Length; i++) { for (int j = 0; j < 32; j++) { if (cbes[i] != null) { if ((int)cbes[i].PrivateKey[j] == (int)cbes[i].PrivateKeyAttempt[j]) { overallstats[j]++; } } else //if the buffer is not full yet, abort. { UpdateWeights(); return; } } } //Create a metric out of these stats double metric = 0; for (int i = 0; i < 32; i++) { metric += overallstats[i]; } //If there is no previous metric, create it, update weights and return if (oldMetric == double.MaxValue) { oldMetric = metric; UpdateWeights(); return; } //If the metric is less than the previous metric, either crash or increment deathrate if (metric < oldMetric) { if (currentDeathRate > deathRate) { parentWeights.Clear(); currentDeathRate = 0; UpdateWeights(); cb.Clear(); return; } else { currentDeathRate++; UpdateWeights(); return; } } else if (metric > oldMetric) //If it does exceed previous metric, we have an improvement, so print it out to the screen { oldMetric = metric; parentWeights.Clear(); parentWeights.Add(new double[] { 1, 2, 3 }); Console.WriteLine(string.Format("Metric: {32} - {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20}, {21}, {22}, {23}, {24}, {25}, {26}, {27}, {28}, {29}, {30}, {31}", overallstats[0], overallstats[1], overallstats[2], overallstats[3], overallstats[4], overallstats[5], overallstats[6], overallstats[7], overallstats[8], overallstats[9], overallstats[10], overallstats[11], overallstats[12], overallstats[13], overallstats[14], overallstats[15], overallstats[16], overallstats[17], overallstats[18], overallstats[19], overallstats[20], overallstats[21], overallstats[22], overallstats[23], overallstats[24], overallstats[25], overallstats[26], overallstats[27], overallstats[28], overallstats[29], overallstats[30], overallstats[31], metric)); //Validation //For validation we require fairly high numbers across all byte positions since the last crash. return; } else //No change { currentDeathRate++; UpdateWeights(); return; } } else //No match, so increment death rate { currentDeathRate++; } if (currentDeathRate > deathRate) { parentWeights.Clear(); currentDeathRate = 0; UpdateWeights(); cb.Clear(); return; } }