@@ -745,7 +745,7 @@ void initialize(sys::state& state) {
745
745
province::for_each_land_province (state, [&](dcon::province_id p) {
746
746
auto fp = fatten (state.world , p);
747
747
// max size of exploitable land:
748
- auto max_rgo_size = std::ceil (state.map_state .map_data .province_area_km2 [province::to_map_id (p)]);
748
+ auto max_rgo_size = std::ceil (100 . f * state.map_state .map_data .province_area_km2 [province::to_map_id (p)]);
749
749
// currently exploited land
750
750
float pop_amount = 0 .0f ;
751
751
for (auto pt : state.world .in_pop_type ) {
@@ -836,7 +836,7 @@ void initialize(sys::state& state) {
836
836
state.world .for_each_commodity ([&](dcon::commodity_id c) {
837
837
auto fc = fatten (state.world , c);
838
838
assert (std::isfinite (true_distribution[c.index ()]));
839
- auto proposed_size = (pop_amount * 10 .f + state.defines .alice_base_rgo_employment_bonus ) * true_distribution[c.index ()];
839
+ auto proposed_size = (pop_amount * 20 .f + state.defines .alice_base_rgo_employment_bonus ) * true_distribution[c.index ()];
840
840
if (proposed_size > state.defines .alice_secondary_rgos_min_employment ) {
841
841
state.world .province_set_rgo_size (p, c,
842
842
state.world .province_get_rgo_size (p, c) + proposed_size
@@ -1691,37 +1691,47 @@ void update_pop_consumption(
1691
1691
return state.world .market_get_luxury_needs_costs (m, pt);
1692
1692
}, markets, pop_type
1693
1693
);
1694
+
1695
+ ve::fp_vector old_life = pop_demographics::get_life_needs (state, ids);
1696
+ ve::fp_vector old_everyday = pop_demographics::get_everyday_needs (state, ids);
1697
+ ve::fp_vector old_luxury = pop_demographics::get_luxury_needs (state, ids);
1698
+
1694
1699
auto pop_size = state.world .pop_get_size (ids);
1695
1700
auto savings = state.world .pop_get_savings (ids);
1696
1701
auto subsistence = ve_adjusted_subsistence_score (state, provs);
1697
1702
1703
+ auto rgo_worker = state.world .pop_type_get_is_paid_rgo_worker (pop_type);
1704
+ subsistence = ve::select (rgo_worker, subsistence, 0 .f );
1705
+
1698
1706
auto available_subsistence = ve::min (subsistence_score_life, subsistence);
1699
1707
subsistence = subsistence - available_subsistence;
1700
- auto life_needs_satisfaction = available_subsistence / subsistence_score_life;
1708
+ auto qol_from_subsistence = available_subsistence / subsistence_score_life;
1701
1709
1702
- auto everyday_needs_satisfaction = ve::fp_vector{ 0 .f };
1703
- auto luxury_needs_satisfaction = ve::fp_vector{ 0 .f };
1710
+ auto base_qol = 0 .5f ;
1704
1711
1705
- // calculate market expenses
1712
+ auto demand_scale_life = old_life / base_qol;
1713
+ auto demand_scale_everyday = old_everyday / base_qol;
1714
+ auto demand_scale_luxury = old_luxury / base_qol;
1706
1715
1707
- auto life_to_satisfy = ve::max ( 0 . f , 1 . f - life_needs_satisfaction) ;
1708
- auto everyday_to_satisfy = ve::max ( 0 . f , 1 . f - everyday_needs_satisfaction) ;
1709
- auto luxury_to_satisfy = ve::max ( 0 . f , 1 . f - luxury_needs_satisfaction) ;
1716
+ demand_scale_life = demand_scale_life * demand_scale_life ;
1717
+ demand_scale_everyday = demand_scale_everyday * demand_scale_everyday ;
1718
+ demand_scale_luxury = demand_scale_luxury * demand_scale_luxury ;
1710
1719
1720
+ // calculate market expenses
1711
1721
auto required_spendings_for_life_needs =
1712
- life_to_satisfy
1713
- * life_costs
1714
- * pop_size / state.defines .alice_needs_scaling_factor ;
1722
+ demand_scale_life * life_costs
1723
+ * pop_size
1724
+ / state.defines .alice_needs_scaling_factor ;
1715
1725
1716
1726
auto required_spendings_for_everyday_needs =
1717
- everyday_to_satisfy
1718
- * everyday_costs
1719
- * pop_size / state.defines .alice_needs_scaling_factor ;
1727
+ demand_scale_everyday * everyday_costs
1728
+ * pop_size
1729
+ / state.defines .alice_needs_scaling_factor ;
1720
1730
1721
1731
auto required_spendings_for_luxury_needs =
1722
- luxury_to_satisfy
1723
- * luxury_costs
1724
- * pop_size / state.defines .alice_needs_scaling_factor ;
1732
+ demand_scale_luxury * luxury_costs
1733
+ * pop_size
1734
+ / state.defines .alice_needs_scaling_factor ;
1725
1735
1726
1736
// if goods are way too expensive:
1727
1737
// reduce spendings, possibly to zero
@@ -1735,7 +1745,8 @@ void update_pop_consumption(
1735
1745
1736
1746
// we want to focus on life needs first if we are poor AND our satisfaction is low
1737
1747
auto is_poor = ve::max (0 .f , 1 .f - 4 .f * savings / (0 .00001f + required_spendings_for_life_needs));
1738
- is_poor = ve::min (1 .f , ve::max (0 .f , is_poor + life_to_satisfy));
1748
+ auto current_life = pop_demographics::get_life_needs (state, ids);
1749
+ is_poor = ve::min (1 .f , ve::max (0 .f , is_poor + (1 .f - current_life) * 2 .f ));
1739
1750
1740
1751
auto life_spending_mod = // ve::fp_vector{ 1.f };
1741
1752
(savings * state.defines .alice_needs_lf_spend ) * (1 .f - is_poor) + is_poor;
@@ -1791,21 +1802,21 @@ void update_pop_consumption(
1791
1802
1792
1803
// buy life needs
1793
1804
1794
- auto spend_on_life_needs = life_spending_mod * ve::min (savings, required_spendings_for_life_needs);
1805
+ auto spend_on_life_needs = ve::min (life_spending_mod * savings, required_spendings_for_life_needs);
1795
1806
auto satisfaction_life_money = ve::select (
1796
1807
zero_life_costs,
1797
- life_to_satisfy ,
1808
+ 1 . f ,
1798
1809
spend_on_life_needs / required_spendings_for_life_needs);
1799
1810
1800
1811
savings = savings - spend_on_life_needs;
1801
1812
total_spendings = total_spendings + spend_on_life_needs;
1802
1813
1803
1814
// buy everyday needs
1804
1815
1805
- auto spend_on_everyday_needs = everyday_spending_mod * ve::min (savings, required_spendings_for_everyday_needs);
1816
+ auto spend_on_everyday_needs = ve::min (everyday_spending_mod * savings, required_spendings_for_everyday_needs);
1806
1817
auto satisfaction_everyday_money = ve::select (
1807
1818
zero_everyday_costs,
1808
- everyday_to_satisfy ,
1819
+ 1 . f ,
1809
1820
spend_on_everyday_needs / required_spendings_for_everyday_needs);
1810
1821
1811
1822
savings = savings - spend_on_everyday_needs;
@@ -1842,72 +1853,80 @@ void update_pop_consumption(
1842
1853
1843
1854
// buy luxury needs
1844
1855
1845
- auto spend_on_luxury_needs = luxury_spending_mod * ve::min (savings, required_spendings_for_luxury_needs);
1856
+ auto spend_on_luxury_needs = ve::min (luxury_spending_mod * savings, required_spendings_for_luxury_needs);
1846
1857
auto satisfaction_luxury_money = ve::select (
1847
1858
zero_luxury_costs,
1848
- luxury_to_satisfy ,
1859
+ 1 . f ,
1849
1860
spend_on_luxury_needs / required_spendings_for_luxury_needs);
1850
1861
1851
1862
savings = savings - spend_on_luxury_needs;
1852
1863
total_spendings = total_spendings + spend_on_luxury_needs;
1853
1864
1854
- ve::fp_vector old_life = pop_demographics::get_life_needs (state, ids);
1855
- ve::fp_vector old_everyday = pop_demographics::get_everyday_needs (state, ids);
1856
- ve::fp_vector old_luxury = pop_demographics::get_luxury_needs (state, ids);
1857
-
1858
1865
savings = savings * (
1859
1866
1 .f
1860
1867
- state.defines .alice_needs_lf_spend
1861
1868
- state.defines .alice_needs_ev_spend
1862
1869
- state.defines .alice_needs_lx_spend
1863
1870
);
1864
1871
1865
- // suppose that old satisfaction was calculated
1866
- // for the same local subsistence conditions and find "raw" satisfaction
1867
- // old = raw + sub ## first summand is "raw satisfaction"
1868
- // we assume that currently calculated satisfaction is caused only by subsistence
1869
-
1870
- auto old_life_money =
1871
- ve::max (0 .f , old_life - life_needs_satisfaction);
1872
- auto old_everyday_money =
1873
- ve::max (0 .f , old_everyday - everyday_needs_satisfaction);
1874
- auto old_luxury_money =
1875
- ve::max (0 .f , old_luxury - luxury_needs_satisfaction);
1876
-
1877
- auto delayed_life_from_money =
1878
- (old_life_money * 0 .5f ) + (satisfaction_life_money * 0 .5f );
1879
- auto delayed_everyday_from_money =
1880
- (old_everyday_money * 0 .5f ) + (satisfaction_everyday_money * 0 .5f );
1881
- auto delayed_luxury_from_money =
1882
- (old_luxury_money * 0 .5f ) + (satisfaction_luxury_money * 0 .5f );
1872
+ // subsistence gives free "level of consumption"
1873
+
1874
+ auto base_shift = ve::fp_vector{ 1 .f / 200 .f };
1875
+
1876
+ ve::fp_vector shift_life = ve::select (
1877
+ satisfaction_life_money + qol_from_subsistence > 0 .9f ,
1878
+ base_shift,
1879
+ ve::select (
1880
+ satisfaction_life_money + qol_from_subsistence < 0 .7f ,
1881
+ -base_shift,
1882
+ ve::fp_vector{ 0 .f }
1883
+ )
1884
+ );
1885
+ ve::fp_vector shift_everyday = ve::select (
1886
+ satisfaction_everyday_money > 0 .9f ,
1887
+ base_shift,
1888
+ ve::select (
1889
+ satisfaction_everyday_money < 0 .7f ,
1890
+ -base_shift,
1891
+ ve::fp_vector{ 0 .f }
1892
+ )
1893
+ );
1894
+ ve::fp_vector shift_luxury = ve::select (
1895
+ satisfaction_luxury_money > 0 .9f ,
1896
+ base_shift,
1897
+ ve::select (
1898
+ satisfaction_luxury_money < 0 .7f ,
1899
+ -base_shift,
1900
+ ve::fp_vector{ 0 .f }
1901
+ )
1902
+ );
1883
1903
1884
1904
// clamping for now
1885
- auto result_life = ve::max (0 .f , ve::min (1 .f , delayed_life_from_money + life_needs_satisfaction ));
1886
- auto result_everyday = ve::max (0 .f , ve::min (1 .f , delayed_everyday_from_money + everyday_needs_satisfaction ));
1887
- auto result_luxury = ve::max (0 .f , ve::min (1 .f , delayed_luxury_from_money + luxury_needs_satisfaction ));
1905
+ auto result_life = ve::max (0 .f , ve::min (1 .f , old_life + shift_life ));
1906
+ auto result_everyday = ve::max (0 .f , ve::min (1 .f , old_everyday + shift_everyday ));
1907
+ auto result_luxury = ve::max (0 .f , ve::min (1 .f , old_luxury + shift_luxury ));
1888
1908
1889
1909
ve::apply ([&](float life, float everyday, float luxury) {
1890
1910
assert (life >= 0 .f && life <= 1 .f );
1891
1911
assert (everyday >= 0 .f && everyday <= 1 .f );
1892
1912
assert (luxury >= 0 .f && luxury <= 1 .f );
1893
1913
}, result_life, result_everyday, result_luxury);
1894
1914
1895
-
1896
1915
pop_demographics::set_life_needs (state, ids, result_life);
1897
1916
pop_demographics::set_everyday_needs (state, ids, result_everyday);
1898
1917
pop_demographics::set_luxury_needs (state, ids, result_luxury);
1899
1918
1900
1919
auto final_demand_scale_life =
1901
1920
pop_size / state.defines .alice_needs_scaling_factor
1902
- * delayed_life_from_money ;
1921
+ * demand_scale_life ;
1903
1922
1904
1923
auto final_demand_scale_everyday =
1905
1924
pop_size / state.defines .alice_needs_scaling_factor
1906
- * delayed_everyday_from_money ;
1925
+ * demand_scale_everyday ;
1907
1926
1908
1927
auto final_demand_scale_luxury =
1909
1928
pop_size / state.defines .alice_needs_scaling_factor
1910
- * delayed_luxury_from_money ;
1929
+ * demand_scale_luxury ;
1911
1930
1912
1931
ve::apply ([&](
1913
1932
dcon::market_id m,
@@ -4334,13 +4353,7 @@ void daily_update(sys::state& state, bool presimulation, float presimulation_sta
4334
4353
// rgo production
4335
4354
update_province_rgo_production (state, p.get_province (), market, n);
4336
4355
4337
- /* adjust pop satisfaction based on consumption and subsistence */
4338
-
4339
- float subsistence = adjusted_subsistence_score (state, p.get_province ());
4340
- float subsistence_life = std::clamp (subsistence, 0 .f , subsistence_score_life);
4341
- subsistence -= subsistence_life;
4342
-
4343
- subsistence_life /= subsistence_score_life;
4356
+ // are pops actually able to maintain their lifestyle? check shortages:
4344
4357
4345
4358
for (auto pl : p.get_province ().get_pop_location ()) {
4346
4359
auto t = pl.get_pop ().get_poptype ();
@@ -4349,25 +4362,19 @@ void daily_update(sys::state& state, bool presimulation, float presimulation_sta
4349
4362
auto en = pop_demographics::get_everyday_needs (state, pl.get_pop ());
4350
4363
auto lx = pop_demographics::get_luxury_needs (state, pl.get_pop ());
4351
4364
4352
-
4353
- // sat = raw + sub ## first summand is "raw satisfaction"
4354
- ln -= subsistence_life;
4355
-
4356
- // as it a very rough estimation based on very rough values,
4357
- // we have to sanitise values:
4358
- ln = std::max (0 .f , ln);
4359
- en = std::max (0 .f , en);
4360
- lx = std::max (0 .f , lx);
4361
-
4362
4365
assert (std::isfinite (ln));
4363
4366
assert (std::isfinite (en));
4364
4367
assert (std::isfinite (lx));
4368
+
4369
+ auto not_enough_life = state.world .market_get_max_life_needs_satisfaction (market, t) < 0 .5f ;
4370
+ auto not_enough_everyday = state.world .market_get_max_everyday_needs_satisfaction (market, t) < 0 .5f ;
4371
+ auto not_enough_luxury = state.world .market_get_max_luxury_needs_satisfaction (market, t) < 0 .5f ;
4365
4372
4366
- ln = std::min (1 .f , ln) * state.world .market_get_max_life_needs_satisfaction (market, t);
4367
- en = std::min (1 .f , en) * state.world .market_get_max_everyday_needs_satisfaction (market, t);
4368
- lx = std::min (1 .f , lx) * state.world .market_get_max_luxury_needs_satisfaction (market, t);
4373
+ auto shift = 1 .f / 200 .f ;
4369
4374
4370
- ln = std::min (1 .f , ln + subsistence_life);
4375
+ ln = not_enough_life ? std::max (0 .f , ln - shift) : ln;
4376
+ en = not_enough_everyday ? std::max (0 .f , en - shift) : en;
4377
+ lx = not_enough_luxury ? std::max (0 .f , lx - shift) : lx;
4371
4378
4372
4379
pop_demographics::set_life_needs (state, pl.get_pop (), ln);
4373
4380
pop_demographics::set_everyday_needs (state, pl.get_pop (), en);
0 commit comments