Пример #1
0
        public void ApplyDistrictProperties(List <DistrictGenerator> districts)
        {
            IList <DistrictEffect> populationDensityEffects = GetPopulationDensityEffects(districts);
            IList <DistrictEffect> urbanisationEffects      = GetUrbanisationEffects(districts);
            IList <DistrictEffect> coastalnessEffects       = GetCoastalnessEffects(districts);
            IList <DistrictEffect> wealthEffects            = GetWealthEffects(districts);
            IList <DistrictEffect> ageEffects              = GetAgeEffects(districts);
            IList <DistrictEffect> educationEffects        = GetEducationEffects(districts);
            IList <DistrictEffect> healthEffects           = GetHealthEffects(districts);
            IList <DistrictEffect> geographicDivideEffects = GetGeographicDivideEffects(districts);

            foreach (var district in districts)
            {
                // 8 people per square km is the western isles.
                // 42 people per square km is Stirling (district).
                // 68 people per square km is South Lakeland.
                // 150 people per square km is Cornwall.
                // 179 people per square km is South Lanarkshire.
                // 280 people per square km is Fife.
                // 1500 per square km is London (greater metropolitan area average) or Sheffield.
                // 3550 per square km is Glasgow
                // 5000 per square km is Portsmouth, the highest district outside London.
                // 15000 per square km is Tower Hamlets.

                // The median for England as a whole is ~900.
                district.PopulationDensity = populationDensityEffects.AccumulateValues(district).Constrain(5, 15000);
                district.Population        = (int)Math.Round(district.PopulationDensity * district.Area / PixelsPerSquareKm);

                district.Urbanisation     = urbanisationEffects.AccumulateValues(district).Constrain(0, 1);
                district.Coastalness      = coastalnessEffects.AccumulateValues(district).Constrain(0, 1);
                district.Wealth           = wealthEffects.AccumulateValues(district).Constrain(0, 1);
                district.Age              = ageEffects.AccumulateValues(district).Constrain(0, 1);
                district.Education        = educationEffects.AccumulateValues(district).Constrain(0, 1);
                district.Health           = healthEffects.AccumulateValues(district).Constrain(0, 1);
                district.GeographicDivide = geographicDivideEffects.AccumulateValues(district).Constrain(0, 1);
            }
        }