Skip to content

Commit

Permalink
Merge pull request #1897 from ineveraskedforthis/budget-1
Browse files Browse the repository at this point in the history
Budget prediction improvements
  • Loading branch information
schombert authored Feb 7, 2025
2 parents 3a1a234 + b7cfa9e commit 023cfba
Show file tree
Hide file tree
Showing 14 changed files with 1,814 additions and 1,390 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ list(APPEND ALICE_INCREMENTAL_SOURCES_LIST
"src/economy/economy_stats.cpp"
"src/economy/economy.cpp"
"src/economy/economy_government.cpp"
"src/economy/construction.cpp"
"src/gamestate/commands.cpp"
"src/gamestate/diplomatic_messages.cpp"
"src/gamestate/modifiers.cpp"
Expand Down
1 change: 1 addition & 0 deletions src/ai/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "system_state.hpp"
#include "demographics.hpp"
#include "economy_stats.hpp"
#include "construction.hpp"
#include "effects.hpp"
#include "gui_effect_tooltips.hpp"
#include "math_fns.hpp"
Expand Down
1,175 changes: 1,175 additions & 0 deletions src/economy/construction.cpp

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions src/economy/construction.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#pragma once
#include "dcon_generated.hpp"

namespace sys {
struct state;
}

namespace economy {

void populate_construction_consumption(sys::state& state);

struct unit_construction_data {
bool can_be_advanced;
float construction_time;
float cost_multiplier;
dcon::nation_id owner;
dcon::market_id market;
dcon::province_id province;
dcon::unit_type_id unit_type;
};
struct province_construction_spending_entry {
dcon::province_building_construction_id construction;
float spending;
};
struct state_construction_spending_entry {
dcon::state_building_construction_id construction;
float spending;
};
struct province_land_construction_spending_entry {
dcon::province_land_construction_id construction;
float spending;
};
struct province_naval_construction_spending_entry {
dcon::province_naval_construction_id construction;
float spending;
};
struct construction_spending_explanation {
int32_t ongoing_projects;
float budget_limit_per_project;
float estimated_spendings;
std::vector<province_construction_spending_entry> province_buildings;
std::vector<state_construction_spending_entry> factories;
std::vector<province_land_construction_spending_entry> land_units;
std::vector<province_naval_construction_spending_entry> naval_units;
};
struct construction_spending_explanation_light {
int32_t ongoing_projects;
float budget_limit_per_project;
float estimated_spendings;
float province_buildings;
float factories;
float land_units;
float naval_units;
};

construction_spending_explanation explain_construction_spending(
sys::state& state,
dcon::nation_id n,
float dedicated_budget
);
void populate_private_construction_consumption(sys::state& state);
void advance_construction(sys::state& state, dcon::nation_id n, float total_spent_on_construction);
void emulate_construction_demand(sys::state& state, dcon::nation_id n);
construction_spending_explanation explain_construction_spending_now(sys::state& state, dcon::nation_id n);
economy::commodity_set calculate_factory_refit_goods_cost(sys::state& state, dcon::nation_id n, dcon::state_instance_id sid, dcon::factory_type_id from, dcon::factory_type_id to);
float calculate_factory_refit_money_cost(sys::state& state, dcon::nation_id n, dcon::state_instance_id sid, dcon::factory_type_id from, dcon::factory_type_id to);

float estimate_construction_spending_from_budget(sys::state& state, dcon::nation_id n, float current_budget);
float estimate_construction_spending(sys::state& state, dcon::nation_id n);
}
Loading

0 comments on commit 023cfba

Please sign in to comment.