示例#1
0
        private void Calculations()
        {
            if (points > 0 && points < 4)
            {
                if (pointUpdateOccures)
                {
                    ChangeStrategy();
                }

                forecastResult = new CeForecast();
                var area            = GetSurfaceArea();
                var weatherForecast = weatherAPI.GetForecast();
                var weather         = new List <double>();
                weatherForecast.ForEach(x => weather.Add(x * area));
                float current = GetCurrentFluidLevel();

                for (int i = 0; i < weatherForecast.Count; i++)
                {
                    ChangeStrategy();
                    for (int j = 0; j < 4; j++)
                    {
                        var income = ((float)weather[i]) / 4;
                        current += income;

                        if (skip && i == 0)
                        {
                            current -= income;
                            skip     = false;
                            break;
                        }

                        result = algorithm.Start(current);
                        var processedResult = ProcessResult(current, result);
                        forecastResult.Results.AddRange(processedResult);
                        current -= GetTotalFromResults(result.Genes);
                    }
                }

                SendCommand(forecastResult);
                Update(forecastResult, weather);
            }
        }