Something went wrong. Try again.
[Mirror] Libreopolis is a cross-platform city simulation game fully compatible with SimCity 2000. gitlab.com/conasg/libreopolis
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152// Verifies the live funding-% plumbing (simulation.hpp phase_fields → coverage.hpp): the police/fire// coverage strength now scales with the budget funding rate (records 5/6), and new cities default to// 100% service funding + 7% tax (the original's default). Synthetic city — no assets needed.#include "sc2k/sim/simulation.hpp"#include "sc2k/sim/terrain_gen.hpp"#include <cstdio>
using namespace sc2k;
#include "test_harness.hpp"
// Sum of the XPLC police-coverage field after running the sim past the tick-2 field scan.static long police_coverage_at(int fundingPct) { City c; c.set_funds(50000); c.xbld.at(40, 40) = 0xD2; // a police station tile c.xzon.at(40, 40) = std::uint8_t(c.xzon.at(40, 40) | 0x80); // active (XZON bit 7) c.xbit.at(40, 40) = std::uint8_t(c.xbit.at(40, 40) | 0x40); // powered c.set_budget_rate(5, fundingPct); // police funding % Simulation sim(c); // holds a City& — mutates `c` in place for (int i = 0; i < 30; ++i) sim.tick(); // run past tick 2 (the police/fire stencil) long s = 0; for (auto v : c.xplc.cells) s += v; return s;}
int main() { // --- New cities default to the faithful budget rates --- { City nc = make_new_city(0x1234u, 2, 1, 50, 50, 50, 0, 0); CHECK(nc.budget_rate(5) == 100); // police funding 100% CHECK(nc.budget_rate(6) == 100); // fire funding 100% CHECK(nc.budget_rate(0) == 7); // residential tax 7% CHECK(nc.budget_rate(3) == 1); // ordinances }
// --- Coverage scales with police funding (monotone; zero funding → no coverage) --- const long c100 = police_coverage_at(100); const long c50 = police_coverage_at(50); const long c0 = police_coverage_at(0); std::printf(" police coverage Σ XPLC: fund100=%ld fund50=%ld fund0=%ld\n", c100, c50, c0); CHECK(c100 > 0); CHECK(c0 == 0); // 0% funding → no police coverage at all CHECK(c100 > c50 && c50 > c0); // under-funding strictly degrades coverage
if (failures == 0) std::printf("funding: all checks passed\n"); else std::printf("funding: %d FAILED\n", failures); return failures ? 1 : 0;}