public override void Step(CityMap cityMap) { object[] parameters = { XIndex, YIndex }; int xMiddle = cityMap.XSize / 2; int yMiddle = cityMap.YSize / 2; int randVal = cityMap.rand.Next(); double randomChanceWithHouse = cityMap.CountPercentTypeAround(XIndex, YIndex, 4, typeof(House)); double randomChanceWithCommercialBuildingNear = cityMap.CountPercentTypeAround(XIndex, YIndex, 2, typeof(CommercialBuilding)); double randomChanceWithHighRiseNear = cityMap.CountPercentTypeAround(XIndex, YIndex, 2, typeof(HighRise)); double randomChanceWithEmptyFar = cityMap.CountPercentTypeAround(XIndex, YIndex, 4, typeof(Empty)); double randomChanceWithSurroundingBias; if (randomChanceWithEmptyFar < 0.001) { randomChanceWithSurroundingBias = 100000 * randomChanceWithHighRiseNear + 100 * randomChanceWithCommercialBuildingNear; } else { randomChanceWithSurroundingBias = 0; } double percentCenterBias = CalculateCenterBias(xMiddle, yMiddle, 100, 1); double randomOddsOfPromotion = (randomChanceWithSurroundingBias * PromotionMultiplierOnUpgradeType) + RandomChancePromotion; randomOddsOfPromotion = randomOddsOfPromotion * percentCenterBias; if (randVal < Int32.MaxValue * randomOddsOfPromotion) { CityStructure newStructure = (CityStructure)Activator.CreateInstance(typeof(HighRise), parameters); cityMap[XIndex, YIndex] = newStructure; } }
private double CalculateSurroundingEffectOnHousePromote(CityMap cityMap, double housePromoteProbability) { double contributingEffect = cityMap.CountPercentTypeAround(XIndex, YIndex, 3, typeof(CommercialBuilding)) + cityMap.CountPercentTypeAround(XIndex, YIndex, 3, typeof(House)); return(contributingEffect * housePromoteProbability); }