Ejemplo n.º 1
0
        private void drawMap(CityMap cityMap)
        {
            CityStructure structureType;

            for (int i = 0; i < cityMap.XSize; i++)
            {
                for (int j = 0; j < cityMap.YSize; j++)
                {
                    structureType = cityMap[i, j];
                    if (structureType.GetType() == typeof(Empty))
                    {
                        graphics.FillRectangle(greenBrush, i * widthOfStruct, j * heightOfStruct, widthOfStruct, heightOfStruct);
                    }
                    if (structureType.GetType() == typeof(House))
                    {
                        graphics.FillRectangle(brownBrush, i * widthOfStruct, j * heightOfStruct, widthOfStruct, heightOfStruct);
                    }
                    if (structureType.GetType() == typeof(CommercialBuilding))
                    {
                        graphics.FillRectangle(purpleBrush, i * widthOfStruct, j * heightOfStruct, widthOfStruct, heightOfStruct);
                    }
                    if (structureType.GetType() == typeof(HighRise))
                    {
                        graphics.FillRectangle(yellowBrush, i * widthOfStruct, j * heightOfStruct, widthOfStruct, heightOfStruct);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        private double CalculateCenterEffectOnHousePromote(CityMap cityMap, double housePromoteProbability)
        {
            int    xMiddle = cityMap.XSize / 2;
            int    yMiddle = cityMap.YSize / 2;
            double contributingEffect;

            contributingEffect = CalculateCenterBias(xMiddle, yMiddle, 4, 1);
            if (housePromoteProbability < 0.001)
            {
                return(contributingEffect);
            }
            else
            {
                return(contributingEffect / 10.0);
            }
        }
Ejemplo n.º 5
0
 public City(int xSize, int ySize)
 {
     cityMap = new CityMap(xSize, ySize);
 }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
 public abstract void Step(CityMap cityMap);