private void Button_Click(object sender, RoutedEventArgs e)
 {
     for (int i = 0; i < SpawnQuantity; i++) {
         bool newCity = rand.NextDouble() <= SpawnAlpha;
         if (newCity) {
             this.cities.Add(1);
             TotalPopulation++;
         } else {
             int cityVal = rand.Next(TotalPopulation);
             int localCount = 0;
             for (int j = 0; j < cities.Count(); j++) {
                 localCount += (int)Math.Round(cities[j]);
                 if (localCount > cityVal) {
                     cities[j]++;
                     TotalPopulation++;
                     break;
                 }
             }
         }
         ///Check if we are going to spawn a new city,
         ///if not, pick the city to join
     }
     this.citySizes.Text = string.Concat(cities.Select(k => k + ","));
     this.histogram = new Histogram(cities, "cities");
     this.HistogramGrid.Children.Clear();
     this.HistogramGrid.Children.Add(this.histogram);
 }
Beispiel #2
0
 private void Histogram_Click(object sender, RoutedEventArgs e)
 {
     h = new Histogram(ratios, "", .05);
     addChart(h, "Histogram");
 }