Skip to content

Commit

Permalink
more percents -> fraction
Browse files Browse the repository at this point in the history
  • Loading branch information
gawquon committed Oct 24, 2024
1 parent 784b68e commit 4b913ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
15 changes: 7 additions & 8 deletions EU4ToVic3/Source/V3World/EconomyManager/Demand/Market.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ std::map<std::string, double> V3::Market::estimateCulturalPrevalence(const std::
{
auto culturalFactors = initCulturalFactors();

for (const auto& [culture, percent]: cultureData)
for (const auto& [culture, fraction]: cultureData)
{
const auto& taboos = getTaboos(culture, cultures, religions);
const auto& obsessions = getObsessions(culture, cultures);
Expand All @@ -197,15 +197,15 @@ std::map<std::string, double> V3::Market::estimateCulturalPrevalence(const std::
{
continue;
}
culturalFactors.at(taboo) -= percent;
culturalFactors.at(taboo) -= fraction;
}
for (const auto& obsession: obsessions)
{
if (!validateGood(obsession))
{
continue;
}
culturalFactors.at(obsession) += percent;
culturalFactors.at(obsession) += fraction;
}
}

Expand Down Expand Up @@ -281,8 +281,8 @@ double V3::Market::calcPurchaseWeight(double marketShare, const GoodsFulfillment
const double culturalFactor = calcCulturalFactor(culturalPrevalence);
if (culturalFactor > 1)
{
const double percent = culturalFactor - 1;
weight = std::max(weight, percent + (1 - percent) * weight); // (x * 1) + (1 - x)y
const double fraction = culturalFactor - 1;
weight = std::max(weight, fraction + (1 - fraction) * weight); // (x * 1) + (1 - x)y
}

return marketShare * weight * culturalFactor;
Expand Down Expand Up @@ -342,8 +342,7 @@ void V3::Market::calcPopOrders(const int popSize,
const auto& culturalPrevalence = estimateCulturalPrevalence(cultureData, cultures, religions);
const auto& goodsMap = demand.getGoodsMap();

// Assuming enough land for each pop (for now).
for (const auto& [job, jobPercent]: jobData)
for (const auto& [job, jobFraction]: jobData)
{
if (!popTypeMap.contains(job))
{
Expand All @@ -356,7 +355,7 @@ void V3::Market::calcPopOrders(const int popSize,
}
const auto& popType = popTypeMap.at(job);

const double popFactor = calcPopFactor(popSize * jobPercent, popType, defines, laws, lawsMap);
const double popFactor = calcPopFactor(popSize * jobFraction, popType, defines, laws, lawsMap);
const int wealth = estimateWealth(popType.getStrata());

if (!demand.getWealthConsumptionMap().contains(wealth))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ void V3::MarketTracker::integrateBuilding(const Building& building,
BuildingResources subsistenceResources;
const Building& subsistenceBuilding = buildings.at(subState->getHomeState()->getSubsistenceBuilding());
subsistenceResources.evaluateResources(subsistenceBuilding.getPMGroups(), estimatedPMs, PMs, PMGroups);
const double addedWorkingPopPercent = Market::calcAddedWorkingPopFraction(subState->getOwner()->getProcessedData().laws, lawsMap);
const double addedWorkingPopFraction = Market::calcAddedWorkingPopFraction(subState->getOwner()->getProcessedData().laws, lawsMap);

// Track Jobs changed.
double lostSubsistence = marketJobs.createJobs(buildingResources.getJobs(),
subsistenceResources.getJobs(),
p,
defaultRatio,
addedWorkingPopPercent,
addedWorkingPopFraction,
estOwnershipFraction,
{{
"building_financial_district",
Expand Down Expand Up @@ -153,7 +153,7 @@ void V3::MarketTracker::integrateBuilding(const Building& building,
subsistenceResources.getJobs(),
p * urbanFrac,
defaultRatio,
addedWorkingPopPercent,
addedWorkingPopFraction,
{},
{},
popTypes,
Expand All @@ -173,6 +173,7 @@ void V3::MarketTracker::logDebugMarket(const Country& country) const
<< "\nCulture Split:" << breakdownAsTable(marketCulture, 0).str();
}

// Debugging function
std::stringstream V3::MarketTracker::breakdownAsTable(const std::map<std::string, double>& breakdown, const int popCount, const bool asPercent)
{
std::stringstream out;
Expand Down

0 comments on commit 4b913ca

Please sign in to comment.