This project implements a city simulation system that models the growth and development of residential, commercial, and industrial zones over time. The simulation takes into account various factors such as power infrastructure, population dynamics, worker availability, goods production, and pollution spread.
- Dynamic city growth simulation
- Three zone types: Residential (R), Commercial (C), and Industrial (I)
- Infrastructure elements: Roads (-), Power lines (T), Power plants (P)
- Population growth based on adjacency rules and resource availability
- Pollution system that spreads from industrial zones and power plants
- Detailed analysis of city regions and statistics
- Residential Zones (R): Provide workers for commercial and industrial zones
- Industrial Zones (I): Require workers and produce goods, generate pollution
- Commercial Zones (C): Require both workers and goods to grow
- Power Infrastructure: Required for initial zone development
main.cpp
- Program entry point and menu systemRegion.cpp/h
- Core region management and simulation logicCell.cpp/h
- Individual cell representation and stateResidentialSystem.cpp/h
- Residential zone growth rulesCommercialSystem.cpp/h
- Commercial zone growth rulesIndustrialSystem.cpp/h
- Industrial zone management and pollutionStatistics.cpp/h
- Analysis and statistics calculation
- C++ compiler (g++ recommended)
- Make (optional but recommended)
- Clone the repository:
git clone https://github.com/yourusername/simcity-simulation.git
cd simcity-simulation
- Compile using g++:
g++ *.cpp -o simcity
Or if you have make installed:
make
- Prepare your configuration file (e.g.,
config.txt
) with the following format:
region.csv
50
5
Where:
- First line: Region layout file name
- Second line: Maximum time steps
- Third line: Refresh rate
- Create your region layout file (e.g.,
region.csv
) with the city layout:
10,10
R,R,R,-,P,-,I,I,C,C
R,R,R,-,T,-,I,I,C,C
...
- Run the program:
./simcity
-
When prompted, enter the configuration file name (e.g.,
config.txt
) -
The simulation will run and display:
- Initial region state
- Development progress at specified refresh rate
- Final statistics and analysis
R
- Residential ZoneI
- Industrial ZoneC
- Commercial Zone-
- RoadT
- Power Line#
- Power Line over RoadP
- Power Plant
The simulation follows specific rules for each zone type:
- Population 0→1: Requires power OR 1 adjacent populated cell
- Population 1→2: Requires 2 adjacent cells with pop ≥ 1
- Population 2→3: Requires 4 adjacent cells with pop ≥ 2
- Population 3→4: Requires 6 adjacent cells with pop ≥ 3
- Population 4→5: Requires 8 adjacent cells with pop ≥ 4
- Requires 2 workers per population level
- Produces goods equal to population
- Generates pollution based on population
- Requires 1 worker and 1 good per population level
- Prioritized over industrial zones for resource allocation
The simulation implements a priority system for growth:
- Commercial zones before industrial zones
- Higher population cells before lower population cells
- Greater adjacent population before lesser
- Lower Y coordinate before higher
- Lower X coordinate before higher
Feel free to submit issues and enhancement requests.
This project is licensed under the MIT License - see the LICENSE file for details.