#[derive(Debug, Clone, PartialEq)]
pub struct Industry {
pub name: String,
pub lane: u8,
pub c: f64,
pub v: f64,
pub e: f64,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Economy {
pub r: f64,
pub big_s: f64,
pub cv: f64,
pub t: Vec<f64>,
pub phi: f64,
pub rent_imperial: f64,
pub rent_internal: f64,
}
pub fn transform(inds: &[Industry]) -> Economy {
let s: Vec<f64> = inds.iter().map(|i| i.v * i.e).collect();
let big_s: f64 = s.iter().sum();
let cv: f64 = inds.iter().map(|i| i.c + i.v).sum();
let r = big_s / cv;
let t: Vec<f64> = inds
.iter()
.zip(s.iter())
.map(|(i, s_i)| r * (i.c + i.v) - s_i)
.collect();
let mut rent_imperial = 0.0;
let mut rent_internal = 0.0;
let mut phi = 0.0;
for (i, t_i) in inds.iter().zip(t.iter()) {
if i.lane == 0 {
rent_imperial -= t_i;
}
if i.lane == 1 {
rent_internal -= t_i;
}
if *t_i > 0.0 {
phi += t_i;
}
}
Economy {
r,
big_s,
cv,
t,
phi,
rent_imperial,
rent_internal,
}
}
pub fn deck_industries() -> Vec<Industry> {
let rows: [(&str, u8, f64, f64, f64); 13] = [
("export agriculture", 0, 14.0, 10.0, 3.2),
("textile assembly", 0, 10.0, 9.0, 3.0),
("extractive mining", 0, 26.0, 7.0, 2.6),
("migrant agriculture", 1, 9.0, 8.0, 2.4),
("meatpacking", 1, 12.0, 8.0, 2.2),
("logistics depots", 1, 18.0, 9.0, 1.9),
("carceral labor", 1, 4.0, 5.0, 4.0),
("defense aerospace", 2, 34.0, 8.0, 1.1),
("suburban construction", 2, 20.0, 9.0, 1.2),
("professional strata", 2, 16.0, 11.0, 0.9),
("pharma IP", 3, 44.0, 6.0, 1.0),
("platform rents", 3, 52.0, 7.0, 1.1),
("finance", 3, 60.0, 5.0, 0.8),
];
rows.into_iter()
.map(|(name, lane, c, v, e)| Industry {
name: name.to_string(),
lane,
c,
v,
e,
})
.collect()
}