コード例 #1
0
        /// <summary>
        /// Initialize and Allocate Arrays for the Maps, Histories
        /// </summary>
        private void InitMapArrays()
        {
            Map = new ushort[Constants.WorldWidth, Constants.WorldHeight];

            ResHist       = new short[Constants.HistoryLength];
            ComHist       = new short[Constants.HistoryLength];
            IndHist       = new short[Constants.HistoryLength];
            MoneyHist     = new short[Constants.HistoryLength];
            PollutionHist = new short[Constants.HistoryLength];
            CrimeHist     = new short[Constants.HistoryLength];
            MiscHist      = new short[Constants.MiscHistoryLength];

            PopulationDensityMap   = new ByteMap2();
            TrafficDensityMap      = new ByteMap2();
            PollutionDensityMap    = new ByteMap2();
            LandValueMap           = new ByteMap2();
            CrimeRateMap           = new ByteMap2();
            TerrainDensityMap      = new ByteMap4();
            RateOfGrowthMap        = new ShortMap8();
            PowerGridMap           = new ByteMap1();
            FireStationMap         = new ShortMap8();
            FireStationEffectMap   = new ShortMap8();
            PoliceStationMap       = new ShortMap8();
            PoliceStationEffectMap = new ShortMap8();
            ComRateMap             = new ShortMap8();
        }
コード例 #2
0
        /// <summary>
        /// Perform smoothing with or without dithering.
        /// </summary>
        /// <param name="srcMap">Source map.</param>
        /// <param name="destMap">Destination map.</param>
        /// <param name="dither">Function should apply dithering.</param>
        private static void smoothDitherMap(ByteMap2 srcMap, ByteMap2 destMap, bool dither)
        {
            if (dither)
            {
                int x, y = 0, z = 0, dir = 1;

                for (x = 0; x < srcMap.width; x++)
                {
                    for (; y != srcMap.height && y != -1; y += dir)
                    {
                        z +=
                            srcMap.Get((x == 0) ? x : (x - 1), y) +
                            srcMap.Get((x == srcMap.width - 1) ? x : (x + 1), y) +
                            srcMap.Get(x, (y == 0) ? (0) : (y - 1)) +
                            srcMap.Get(x, (y == (srcMap.height - 1)) ? y : (y + 1)) +
                            srcMap.Get(x, y);
                        Byte val = (Byte)(z / 4);
                        destMap.Set(x, y, val);
                        z &= 3;
                    }
                    dir = -dir;
                    y  += dir;
                }
            }
            else
            {
                int x, y, z;

                for (x = 0; x < srcMap.width; x++)
                {
                    for (y = 0; y < srcMap.height; y++)
                    {
                        z = 0;
                        if (x > 0)
                        {
                            z += srcMap.Get(x - 1, y);
                        }
                        if (x < srcMap.width - 1)
                        {
                            z += srcMap.Get(x + 1, y);
                        }
                        if (y > 0)
                        {
                            z += srcMap.Get(x, y - 1);
                        }
                        if (y < (srcMap.height - 1))
                        {
                            z += srcMap.Get(x, y + 1);
                        }
                        z = (z + srcMap.Get(x, y)) >> 2;
                        if (z > 255)
                        {
                            z = 255;
                        }
                        destMap.Set(x, y, (Byte)z);
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Simulator constructor.
        /// </summary>
        public Micropolis()
        {
            PopulationDensityMap = new ByteMap2();
            TrafficDensityMap    = new ByteMap2();
            PollutionDensityMap  = new ByteMap2();
            LandValueMap         = new ByteMap2();
            CrimeRateMap         = new ByteMap2();
            TerrainDensityMap    = new ByteMap4();

            TempMap1 = new ByteMap2();
            TempMap2 = new ByteMap2();
            TempMap3 = new ByteMap2();

            PowerGridMap           = new ByteMap1();
            RateOfGrowthMap        = new ShortMap8();
            FireStationMap         = new ShortMap8();
            FireStationEffectMap   = new ShortMap8();
            PoliceStationMap       = new ShortMap8();
            PoliceStationEffectMap = new ShortMap8();
            ComRateMap             = new ShortMap8();

            init();
        }