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; } }
public override void Step(CityMap cityMap) { object[] parameters = { XIndex, YIndex }; int randVal = cityMap.rand.Next(); double housePromoteProbability = 1; housePromoteProbability = CalculateSurroundingEffectOnHousePromote(cityMap, housePromoteProbability); housePromoteProbability = CalculateCenterEffectOnHousePromote(cityMap, housePromoteProbability); if (randVal < Int32.MaxValue * housePromoteProbability) { CityStructure newStructure = (CityStructure)Activator.CreateInstance(typeof(House), parameters); cityMap[XIndex, YIndex] = newStructure; } }