public static void Main() { int track = 0; WeatherStation weatherStation = new WeatherStation(); DisplayForecast displayForecast = new DisplayForecast(); DisplayStatistics displayStatistics = new DisplayStatistics(); weatherStation.Register(displayStatistics); weatherStation.Register(displayForecast); do { weatherStation.SetData(new Random().Next(100), new Random().Next(100)); track++; Thread.Sleep(5000); } while (track < 5); }
private double GetFitness() { DisplayStatistics stats = GameObject.FindObjectOfType <DisplayStatistics>(); string heaviestSpecie = GetHeaviestSpecie(stats); if (heaviestSpecie == "") { return(0); } float size = stats.speciesSize[heaviestSpecie][0] / stats.speciesSize[heaviestSpecie][1]; float lifespan = (float)stats.speciesLifespan[heaviestSpecie][0] / (float)stats.speciesLifespan[heaviestSpecie][1]; double fitness = Math.Pow(2, Math.Log(size) + 0.25 * Math.Log(lifespan)); return(fitness); }
private string GetHeaviestSpecie(DisplayStatistics stats) { Dictionary <string, float[]> sizes = stats.speciesSize; string heaviest = ""; float maxSize = 0; foreach (var specie in sizes) { float size = specie.Value[0] / specie.Value[1]; if (size > maxSize && stats.speciesAge[specie.Key] >= 10) //&& specie.Value[1] >= 2 { maxSize = size; heaviest = specie.Key; } } return(heaviest); }
public ProxyBuilder(DisplayStatistics callBack, IFileListBuilder fileListBuilder) { _callBack = callBack; _fileListBuilder = fileListBuilder; }