// Integration: with growth ENABLED, ticking a real city evolves its zoned land (develops/abandons) // without corrupting it. Growth is RNG-driven (structural validation), so this checks the live wiring // is sound — change happens, building codes stay valid, the developed count stays sane — not bit-exact. #include "sc2k/sim/simulation.hpp" #include "sc2k/io/sc2_file.hpp" #include #include "test_paths.hpp" using namespace sc2k; #include "test_harness.hpp" static int developed(const City& c) { int n = 0; for (int t = 0; t < City::kTiles; ++t) if (c.xbld.cells[t] >= 112) ++n; // zoned-building codes return n; } int main() { City c; auto r = io::load_sc2((city_file("TOKYO.SC2")), c); if (!r.ok) { std::printf("sim_growth: skipped (%s)\n", r.error.c_str()); return 0; } const int dev0 = developed(c); Simulation sim(c); sim.set_growth_enabled(true); for (int i = 0; i < 25 * 12; ++i) sim.tick(); // a full game year // Diff against a pristine reload: how many XBLD tiles the year of growth changed. City fresh; CHECK(io::load_sc2((city_file("TOKYO.SC2")), fresh).ok); int changed = 0; for (int t = 0; t < City::kTiles; ++t) if (c.xbld.cells[t] != fresh.xbld.cells[t]) ++changed; const int dev1 = developed(c); std::printf("sim_growth: TOKYO 1 year, developed %d -> %d, XBLD tiles changed=%d\n", dev0, dev1, changed); CHECK(changed > 0); // the scan actually did something CHECK(dev1 > dev0 / 2 && dev1 < City::kTiles); // didn't collapse or explode CHECK(sim.clock() == static_cast(fresh.days()) + 25 * 12); if (failures == 0) { std::printf("sim_growth: all checks passed\n"); return 0; } std::printf("sim_growth: %d failure(s)\n", failures); return 1; }