Reinventing a city simulator
Libreopolis began with a fairly innocent desire: I wanted to understand how a classic 1990s city simulator worked.
The sensible response might have been to read about it, poke at a few city files and move on. Mine was to write a new C++20 engine capable of loading those files, rendering their cities and running the simulation. At some point this stopped being an investigation and became a rather comprehensive reinvention of the wheel.
Compatibility as a boundary
The central rule is that original .SC2 city files and .SCN scenarios must
load. Libreopolis also tries to write cities that the original game can still
understand. It does not ship copyrighted assets; it reads them from the user’s
own installation.
The old file format rules out plenty of convenient choices. Tile data is packed into several arrays with assumptions the original game never needed to explain, and Libreopolis has to preserve those assumptions when it saves. A new feature is only harmless if the old game can ignore it or represent it without mangling the rest of the city.
The simulation now covers zoning and growth, transport, the city budget, weather, disasters and the newspaper. It has software and GPU renderers inside an SDL3 application, plus far more tests than I imagined when I started.
Learning without a blueprint
Visual similarity is not enough for a simulation. A city can look right while its population totals are wrong or traffic takes impossible routes. Libreopolis leans heavily on small numerical tests: saving and loading a city without losing information, checking projections and tile orientation, comparing rendering paths, and making sure changes to growth or transport produce stable results.
That discipline is one of the most satisfying parts of the project. When power plants began wearing out, for example, the work was not finished when the first one failed on schedule. Tests now cover their ageing and replacement costs so a later change cannot accidentally make every reactor immortal.
I do have a spiritually new city builder brewing somewhere behind this one. Libreopolis has taught me a great deal about how to build it. The obstacle is art: I can spend an evening fixing traffic or bond repayments, but producing a city’s worth of good buildings and models is a different job. For now, I am still enjoying the engineering problem in front of me.