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.
1234567891011121314151617181920212223242526272829303132// sc2k/sim/workforce.hpp — the city-wide Life-Expectancy (Health) and Education-Quotient figures, the// reduction at the tail of the original's monthly demographic pass.// Each of the 20 age brackets carries a running population (rawpop), an accumulated education// weight (EQ) and an accumulated life weight (LE), interleaved in MISC at dwords 31..90 (rawpop 0x7C+12·b,// EQ 0x80+12·b, LE 0x84+12·b — the same arrays the Population graph reads). The headline LE/EQ are the// population-weighted averages over the seven working-age brackets 4..10:// LE = Σ_{b=4..10} LE[b] / Σ rawpop[b] · EQ = Σ_{b=4..10} EQ[b] / Σ rawpop[b]// VERIFIED byte-exact against the saved Life-Expectancy (MISC 0x48) / Education-Quotient (0x4C) fields on// TOKYO / LONDON / NYC / PARIS / BAYVIEW / BIGGESTC (see tests/test_workforce.cpp).#pragma once#include "sc2k/city.hpp"
namespace sc2k {
struct WorkforceStats { int life_expectancy = 0; int education_quotient = 0;};
inline WorkforceStats compute_workforce(const City& c) { long le = 0, eq = 0, pop = 0; for (int b = 4; b <= 10; ++b) { // the seven working-age brackets pop += c.misc_be32(sc2k::misc::kAgeHistRaw + 12 * b); eq += c.misc_be32(sc2k::misc::kAgeHistEduc + 12 * b); le += c.misc_be32(sc2k::misc::kAgeHistLife + 12 * b); } if (pop == 0) return {0, 0}; return {int(le / pop), int(eq / pop)};}
} // namespace sc2k