示例#1
0
        public City(StartingValues startValues)
        {
            storagePathPeople = startValues.StoragePath;
            storagePathMap    = startValues.StoragePathMap;

            mManager           = new TrafficMutator();
            _budget            = startValues.Budget;
            _traffictCycleTime = startValues.TrafficLightCycleTimeDefault;
            _cityHeight        = startValues.MapHeight;
            _cityWidth         = startValues.MapWidth;
            _population        = startValues.Population;
            _zoning            = new ZoneMap(_cityWidth, _cityHeight);

            LiveMap = new ITile[_cityWidth, _cityHeight];

            TravelTimes = new int[_cityWidth, _cityHeight];


            if (File.Exists(storagePathPeople))
            {
                //GeneratePeople();
                LoadPeopleFromFile();
            }
            else
            {
                _zoning = GenerateZones(_zoning);
                LiveMap = GenerateLiveMap(LiveMap);
                GenerateTravelTimeHelper();
                GeneratePeople();
            }

            PrintCity();
            //The larger the number the more accurate the final prediction
            while (mManager.GetNumberOfCyclesSinceLastKeptChange() < 200000)
            {
                Tick();
            }

            Console.Out.WriteLine("The ideal intersection timing for this city is... [Measured in ticks]");
            PrintFinalOutput();
        }
示例#2
0
        private static void Main(string[] args)
        {
            var config = new StartingValues
            {
                Budget     = 1000000,//1Million
                MapHeight  = 25,
                MapWidth   = 25,
                Population = 1000,
                TrafficLightCycleTimeDefault = 120//Measured in ticks, 60mph = 60ticks
            };
            //TODO Make a storage path to store the tile map and pathing helper
            var ExecutablePath = System.Reflection.Assembly.GetEntryAssembly().CodeBase;

            String[] executableLocation = ExecutablePath.Split('/');
            for (int i = 3; i < executableLocation.Length - 1; i++)
            {
                config.StoragePath = config.StoragePath + executableLocation[i] + "/";
            }
            config.StoragePathMap = config.StoragePath + "mapInfo.json";
            config.StoragePath    = config.StoragePath + "people.json";
            Console.WriteLine(config.StoragePath);
            var city = new City(config);
        }