From 8806d407a44c84a391e1eeed3de0a57ef4138d1f Mon Sep 17 00:00:00 2001
From: ineveraskedforthis <ineveraskedforthis@users.noreply.github.com>
Date: Fri, 29 Nov 2024 10:52:29 +0300
Subject: [PATCH 1/3] half-remove need weights, slight rebalance

---
 src/economy/economy.cpp |  3 +++
 src/economy/economy.hpp |  2 +-
 src/parsing/defines.hpp | 16 ++++++++--------
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/economy/economy.cpp b/src/economy/economy.cpp
index 3cc045b0e..fee5c7d92 100644
--- a/src/economy/economy.cpp
+++ b/src/economy/economy.cpp
@@ -1028,6 +1028,7 @@ void rebalance_needs_weights(sys::state& state, dcon::market_id n) {
 				}
 				auto& w = state.world.market_get_life_needs_weights(n, c);
 				w = ideal_weighting * state.defines.alice_need_drift_speed + w * (1.0f - state.defines.alice_need_drift_speed);
+				w = 1.f;
 
 				assert(std::isfinite(w));
 				assert(w <= count + 0.01f);
@@ -1069,6 +1070,7 @@ void rebalance_needs_weights(sys::state& state, dcon::market_id n) {
 				}
 				auto& w = state.world.market_get_everyday_needs_weights(n, c);
 				w = ideal_weighting * state.defines.alice_need_drift_speed + w * (1.0f - state.defines.alice_need_drift_speed);
+				w = 1.f;
 
 				assert(std::isfinite(w));
 				assert(w <= count + 0.01f);
@@ -1110,6 +1112,7 @@ void rebalance_needs_weights(sys::state& state, dcon::market_id n) {
 				}
 				auto& w = state.world.market_get_luxury_needs_weights(n, c);
 				w = ideal_weighting * state.defines.alice_need_drift_speed + w * (1.0f - state.defines.alice_need_drift_speed);
+				w = 1.f;
 
 				assert(std::isfinite(w));
 				assert(w <= count + 0.01f);
diff --git a/src/economy/economy.hpp b/src/economy/economy.hpp
index 2d9922d95..e158dce78 100644
--- a/src/economy/economy.hpp
+++ b/src/economy/economy.hpp
@@ -122,7 +122,7 @@ inline constexpr float rgo_owners_cut = 0.05f;
 inline constexpr float price_speed_mod = 0.0001f;
 inline constexpr float price_rigging = 0.015f;
 inline constexpr float stockpile_to_supply = 0.1f;
-inline constexpr float production_throughput_multiplier = 2.f;
+inline constexpr float production_throughput_multiplier = 3.f;
 
 void presimulate(sys::state& state);
 void sanity_check(sys::state& state);
diff --git a/src/parsing/defines.hpp b/src/parsing/defines.hpp
index a7d22993e..599e10922 100644
--- a/src/parsing/defines.hpp
+++ b/src/parsing/defines.hpp
@@ -657,22 +657,22 @@
 	LUA_DEFINES_LIST_ELEMENT(alice_full_reinforce, 1.000000)                                                             \
 	LUA_DEFINES_LIST_ELEMENT(alice_ai_offensive_strength_overestimate, 1.000000) \
 	LUA_DEFINES_LIST_ELEMENT(alice_military_score_leadership_factor, 1.000000) \
-	LUA_DEFINES_LIST_ELEMENT(alice_lf_needs_scale, 2.000000) \
-	LUA_DEFINES_LIST_ELEMENT(alice_ev_needs_scale, 4.000000) \
-	LUA_DEFINES_LIST_ELEMENT(alice_lx_needs_scale, 4.000000) \
+	LUA_DEFINES_LIST_ELEMENT(alice_lf_needs_scale, 1.000000) \
+	LUA_DEFINES_LIST_ELEMENT(alice_ev_needs_scale, 1.500000) \
+	LUA_DEFINES_LIST_ELEMENT(alice_lx_needs_scale, 2.500000) \
 	LUA_DEFINES_LIST_ELEMENT(alice_max_event_iterations, 8.000000) \
 	LUA_DEFINES_LIST_ELEMENT(alice_needs_scaling_factor, 400000.000000) \
 	LUA_DEFINES_LIST_ELEMENT(alice_factory_per_level_employment, 10000.0) \
 	LUA_DEFINES_LIST_ELEMENT(alice_domestic_investment_multiplier, 50.0) \
-	LUA_DEFINES_LIST_ELEMENT(alice_rgo_boost, 1.5) \
+	LUA_DEFINES_LIST_ELEMENT(alice_rgo_boost, 1.0) \
 	LUA_DEFINES_LIST_ELEMENT(alice_base_rgo_employment_bonus, 150000.0) \
-	LUA_DEFINES_LIST_ELEMENT(alice_base_rgo_efficiency_bonus, 1.5) \
-	LUA_DEFINES_LIST_ELEMENT(alice_inputs_base_factor_artisans, 1.05) \
-	LUA_DEFINES_LIST_ELEMENT(alice_output_base_factor_artisans, 0.95) \
+	LUA_DEFINES_LIST_ELEMENT(alice_base_rgo_efficiency_bonus, 1.05) \
+	LUA_DEFINES_LIST_ELEMENT(alice_inputs_base_factor_artisans, 1.04) \
+	LUA_DEFINES_LIST_ELEMENT(alice_output_base_factor_artisans, 0.96) \
 	LUA_DEFINES_LIST_ELEMENT(alice_inputs_base_factor, 1.0) \
 	LUA_DEFINES_LIST_ELEMENT(alice_rgo_overhire_multiplier, 10.0) \
 	LUA_DEFINES_LIST_ELEMENT(alice_rgo_production_scale_neg_delta, 0.001) \
-	LUA_DEFINES_LIST_ELEMENT(alice_invest_capitalist, 0.1) \
+	LUA_DEFINES_LIST_ELEMENT(alice_invest_capitalist, 0.2) \
 	LUA_DEFINES_LIST_ELEMENT(alice_invest_aristocrat, 0.0125) \
 	LUA_DEFINES_LIST_ELEMENT(alice_save_capitalist, 0.025) \
 	LUA_DEFINES_LIST_ELEMENT(alice_save_aristocrat, 0.0125) \

From 72dd14ad8fce7fe4d6898c43f89fed78631a82e2 Mon Sep 17 00:00:00 2001
From: ineveraskedforthis <ineveraskedforthis@users.noreply.github.com>
Date: Sat, 30 Nov 2024 11:42:39 +0300
Subject: [PATCH 2/3] More aggressive trade routes culling, less greedy
 artisans, adjust needs balance.

---
 src/economy/economy.cpp |  2 +-
 src/nations/nations.cpp | 16 +++++++++++-----
 src/parsing/defines.hpp | 10 +++++-----
 3 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/economy/economy.cpp b/src/economy/economy.cpp
index fee5c7d92..fa76991f3 100644
--- a/src/economy/economy.cpp
+++ b/src/economy/economy.cpp
@@ -24,7 +24,7 @@ template<typename T>
 ve::fp_vector ve_artisan_min_wage(sys::state& state, T markets) {
 	auto life = state.world.market_get_life_needs_costs(markets, state.culture_definitions.artisans);
 	auto everyday = state.world.market_get_everyday_needs_costs(markets, state.culture_definitions.artisans);
-	return (life + everyday) * 1.1f;
+	return life * 1.5f;
 }
 template<typename T>
 ve::fp_vector ve_farmer_min_wage(sys::state& state, T markets, ve::fp_vector min_wage_factor) {
diff --git a/src/nations/nations.cpp b/src/nations/nations.cpp
index a8b05dc4e..0e23f38e9 100644
--- a/src/nations/nations.cpp
+++ b/src/nations/nations.cpp
@@ -358,7 +358,7 @@ void generate_sea_trade_routes(sys::state& state) {
 			}
 
 			auto population_target = state.world.state_instance_get_demographics(sid, demographics::total);
-			score += std::min(population_origin, population_target) / (400'000.f + world_population * 0.000'100f);
+			score += std::min(population_origin, population_target) / (400'000.f + world_population * 0.000'500f);
 
 			auto state_target_owner_capital = state.world.nation_get_capital(target_owner);
 			auto state_target_owner_capital_state = state.world.province_get_state_membership(state_target_owner_capital);
@@ -376,7 +376,7 @@ void generate_sea_trade_routes(sys::state& state) {
 					score = score + (
 						state.world.nation_get_demographics(owner, demographics::total)
 						+ state.world.nation_get_demographics(target_owner, demographics::total)
-					) / 2'000'000.f * mod;
+					) / (2'000'000.f * mod + world_population * 0.000'500f);
 
 			bool must_connect = same_owner && different_region && capitals_of_regions;
 
@@ -384,14 +384,20 @@ void generate_sea_trade_routes(sys::state& state) {
 				return;
 			}
 
+			auto coast_0 = province::state_get_coastal_capital(state, origin);
+			auto coast_1 = province::state_get_coastal_capital(state, sid);
+
+			auto distance_approximation = province::direct_distance(state, coast_0, coast_1);
+
+			if(!((score / (2.f * distance_approximation / 200.f) >= 4.f) || must_connect)) {
+				return;
+			}
+
 			auto distance = 9999.f;
 			{
 				std::vector<dcon::province_id> path{ };
 				auto speed = base_speed;
 				dcon::province_id p_prev{ };
-
-				auto coast_0 = province::state_get_coastal_capital(state, origin);
-				auto coast_1 = province::state_get_coastal_capital(state, sid);
 				path = province::make_naval_path(state, coast_0, coast_1);
 				p_prev = coast_0;
 
diff --git a/src/parsing/defines.hpp b/src/parsing/defines.hpp
index 599e10922..c0ce6cdd1 100644
--- a/src/parsing/defines.hpp
+++ b/src/parsing/defines.hpp
@@ -657,14 +657,14 @@
 	LUA_DEFINES_LIST_ELEMENT(alice_full_reinforce, 1.000000)                                                             \
 	LUA_DEFINES_LIST_ELEMENT(alice_ai_offensive_strength_overestimate, 1.000000) \
 	LUA_DEFINES_LIST_ELEMENT(alice_military_score_leadership_factor, 1.000000) \
-	LUA_DEFINES_LIST_ELEMENT(alice_lf_needs_scale, 1.000000) \
-	LUA_DEFINES_LIST_ELEMENT(alice_ev_needs_scale, 1.500000) \
-	LUA_DEFINES_LIST_ELEMENT(alice_lx_needs_scale, 2.500000) \
+	LUA_DEFINES_LIST_ELEMENT(alice_lf_needs_scale, 5.000000) \
+	LUA_DEFINES_LIST_ELEMENT(alice_ev_needs_scale, 0.750000) \
+	LUA_DEFINES_LIST_ELEMENT(alice_lx_needs_scale, 0.750000) \
 	LUA_DEFINES_LIST_ELEMENT(alice_max_event_iterations, 8.000000) \
 	LUA_DEFINES_LIST_ELEMENT(alice_needs_scaling_factor, 400000.000000) \
 	LUA_DEFINES_LIST_ELEMENT(alice_factory_per_level_employment, 10000.0) \
 	LUA_DEFINES_LIST_ELEMENT(alice_domestic_investment_multiplier, 50.0) \
-	LUA_DEFINES_LIST_ELEMENT(alice_rgo_boost, 1.0) \
+	LUA_DEFINES_LIST_ELEMENT(alice_rgo_boost, 1.5) \
 	LUA_DEFINES_LIST_ELEMENT(alice_base_rgo_employment_bonus, 150000.0) \
 	LUA_DEFINES_LIST_ELEMENT(alice_base_rgo_efficiency_bonus, 1.05) \
 	LUA_DEFINES_LIST_ELEMENT(alice_inputs_base_factor_artisans, 1.04) \
@@ -672,7 +672,7 @@
 	LUA_DEFINES_LIST_ELEMENT(alice_inputs_base_factor, 1.0) \
 	LUA_DEFINES_LIST_ELEMENT(alice_rgo_overhire_multiplier, 10.0) \
 	LUA_DEFINES_LIST_ELEMENT(alice_rgo_production_scale_neg_delta, 0.001) \
-	LUA_DEFINES_LIST_ELEMENT(alice_invest_capitalist, 0.2) \
+	LUA_DEFINES_LIST_ELEMENT(alice_invest_capitalist, 0.25) \
 	LUA_DEFINES_LIST_ELEMENT(alice_invest_aristocrat, 0.0125) \
 	LUA_DEFINES_LIST_ELEMENT(alice_save_capitalist, 0.025) \
 	LUA_DEFINES_LIST_ELEMENT(alice_save_aristocrat, 0.0125) \

From 049b886588facb486bdd3c149e361a4d1262c205 Mon Sep 17 00:00:00 2001
From: ineveraskedforthis <ineveraskedforthis@users.noreply.github.com>
Date: Sat, 30 Nov 2024 13:16:26 +0300
Subject: [PATCH 3/3] comment out old weights code

---
 src/economy/economy.cpp | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/economy/economy.cpp b/src/economy/economy.cpp
index 4b8f8074b..65072f547 100644
--- a/src/economy/economy.cpp
+++ b/src/economy/economy.cpp
@@ -995,6 +995,7 @@ void rebalance_needs_weights(sys::state& state, dcon::market_id n) {
 	auto zone = state.world.market_get_zone_from_local_market(n);
 	auto nation = state.world.state_instance_get_nation_from_state_ownership(zone);
 
+	/*
 	{
 		float total_weights = 0.f;
 		uint32_t count = 0;
@@ -1028,7 +1029,6 @@ void rebalance_needs_weights(sys::state& state, dcon::market_id n) {
 				}
 				auto& w = state.world.market_get_life_needs_weights(n, c);
 				w = ideal_weighting * state.defines.alice_need_drift_speed + w * (1.0f - state.defines.alice_need_drift_speed);
-				w = 1.f;
 
 				assert(std::isfinite(w));
 				assert(w <= count + 0.01f);
@@ -1070,7 +1070,6 @@ void rebalance_needs_weights(sys::state& state, dcon::market_id n) {
 				}
 				auto& w = state.world.market_get_everyday_needs_weights(n, c);
 				w = ideal_weighting * state.defines.alice_need_drift_speed + w * (1.0f - state.defines.alice_need_drift_speed);
-				w = 1.f;
 
 				assert(std::isfinite(w));
 				assert(w <= count + 0.01f);
@@ -1112,13 +1111,26 @@ void rebalance_needs_weights(sys::state& state, dcon::market_id n) {
 				}
 				auto& w = state.world.market_get_luxury_needs_weights(n, c);
 				w = ideal_weighting * state.defines.alice_need_drift_speed + w * (1.0f - state.defines.alice_need_drift_speed);
-				w = 1.f;
 
 				assert(std::isfinite(w));
 				assert(w <= count + 0.01f);
 			}
 		});
 	}
+
+	*/
+
+	state.world.for_each_commodity([&](dcon::commodity_id c) {
+		if(valid_luxury_need(state, nation, c)) {
+			state.world.market_set_luxury_needs_weights(n, c, 1.f);
+		}
+		if(valid_everyday_need(state, nation, c)) {
+			state.world.market_set_everyday_needs_weights(n, c, 1.f);
+		}
+		if(valid_life_need(state, nation, c)) {
+			state.world.market_set_life_needs_weights(n, c, 1.f);
+		}
+	});
 }