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.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546// Population window data KAT (ui/graph_view.hpp): the 20-bracket age-distribution series for each radio// mode, read from the MISC histograms (pRawPopTable/pEQTable/pLETable @ dwords 31-90). Health = LE per// bracket (pLETable/pop). Verified against LONDON. Skips without the city.#include "sc2k/io/sc2_file.hpp"#include "sc2k/render/asset_loader.hpp"#include "sc2k/ui/graph_view.hpp"#include <cstdio>#include <fstream>#include <string>
#include "test_harness.hpp"#include "test_paths.hpp"int main() { using namespace sc2k; const std::string p = city_file("LONDON.SC2"); if (!exists(p)) { std::printf("popview: SKIP (no LONDON)\n"); return 0; } City c; CHECK(io::load_sc2(p, c).ok);
const auto pop = ui::population_series(c, 0); // headcount per age bracket const auto hp = ui::population_series(c, 1); // life expectancy per bracket // LONDON's known first brackets (verified vs the raw MISC tables). CHECK(pop[0] == 11218 && pop[1] == 10745 && pop[2] == 10292); CHECK(pop[12] == 14629); // the peak bracket int argmax = 0; for (int i = 1; i < 20; ++i) if (pop[i] > pop[argmax]) argmax = i; CHECK(argmax == 12); // Health = life expectancy = pLETable/pop ≈ 86 for the youngest bracket (a sane LE). CHECK(hp[0] >= 80 && hp[0] <= 95); // Education mode is also populated, non-negative. const auto eq = ui::population_series(c, 2); CHECK(eq[0] > 0); std::printf("popview: LONDON brackets pop[0]=%d peak[12]=%d LE[0]=%d — offsets verified\n", pop[0], pop[12], hp[0]);
if (failures == 0) { std::printf("popview: all checks passed\n"); return 0; } std::printf("popview: %d failure(s)\n", failures); return 1;}