-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
City Production Focus (UI) #6144
Comments
I think we already have a UI for locking/unlocking tiles, though whether tiles are locked is not actually used anywhere as far as I know. Focusing population to a single stat is also already marked as todo in #4697. |
We have locking and unlocking individual tiles already. But no button to unlock all tiles yet. |
The problem isn't the UI, it's that the feature isn't well defined. |
I haven't found any code about how the Focus works exactly in Civ 5 as basis. I feel like it does the latter. Make sure you don't starve, then max focused stat, then use standard algo for the rest. I should boot it up and fiddle around. It seems like in Vanilla they had issues where they would starve the city |
Looking a bit through the source code distributed with the game (G&K version), the relevant function appears to be this: GetPlotValue()/// What is the overall value of the current Plot?
int CvCityCitizens::GetPlotValue(CvPlot* pPlot, bool bUseAllowGrowthFlag)
{
int iValue = 0;
// Yield Values
int iFoodYieldValue = (/*12*/ GC.getAI_CITIZEN_VALUE_FOOD() * pPlot->getYield(YIELD_FOOD));
int iProductionYieldValue = (/*8*/ GC.getAI_CITIZEN_VALUE_PRODUCTION() * pPlot->getYield(YIELD_PRODUCTION));
int iGoldYieldValue = (/*10*/ GC.getAI_CITIZEN_VALUE_GOLD() * pPlot->getYield(YIELD_GOLD));
int iScienceYieldValue = (/*6*/ GC.getAI_CITIZEN_VALUE_SCIENCE() * pPlot->getYield(YIELD_SCIENCE));
int iCultureYieldValue = (/*6*/ GC.getAI_CITIZEN_VALUE_CULTURE() * pPlot->getYield(YIELD_CULTURE));
int iFaithYieldValue = (/*5*/ GC.getAI_CITIZEN_VALUE_FAITH() * pPlot->getYield(YIELD_FAITH));
// How much surplus food are we making?
int iExcessFoodTimes100 = m_pCity->getYieldRateTimes100(YIELD_FOOD) - (m_pCity->foodConsumption() * 100);
bool bAvoidGrowth = IsAvoidGrowth();
// City Focus
CityAIFocusTypes eFocus = GetFocusType();
if(eFocus == CITY_AI_FOCUS_TYPE_FOOD)
iFoodYieldValue *= 3;
else if(eFocus == CITY_AI_FOCUS_TYPE_PRODUCTION)
iProductionYieldValue *= 3;
else if(eFocus == CITY_AI_FOCUS_TYPE_GOLD)
iGoldYieldValue *= 3;
else if(eFocus == CITY_AI_FOCUS_TYPE_SCIENCE)
iScienceYieldValue *= 3;
else if(eFocus == CITY_AI_FOCUS_TYPE_CULTURE)
iCultureYieldValue *= 3;
else if(eFocus == CITY_AI_FOCUS_TYPE_GOLD_GROWTH)
{
iFoodYieldValue *= 2;
iGoldYieldValue *= 2;
}
else if(eFocus == CITY_AI_FOCUS_TYPE_PROD_GROWTH)
{
iFoodYieldValue *= 2;
iProductionYieldValue *= 2;
}
else if(eFocus == CITY_AI_FOCUS_TYPE_FAITH)
{
iFaithYieldValue *= 3;
}
// Food can be worth less if we don't want to grow
if(bUseAllowGrowthFlag && iExcessFoodTimes100 >= 0 && bAvoidGrowth)
{
// If we at least have enough Food to feed everyone, zero out the value of additional food
iFoodYieldValue = 0;
}
// We want to grow here
else
{
// If we have a non-default and non-food focus, only worry about getting to 0 food
if(eFocus != NO_CITY_AI_FOCUS_TYPE && eFocus != CITY_AI_FOCUS_TYPE_FOOD && eFocus != CITY_AI_FOCUS_TYPE_PROD_GROWTH && eFocus != CITY_AI_FOCUS_TYPE_GOLD_GROWTH)
{
int iFoodT100NeededFor0 = -iExcessFoodTimes100;
if(iFoodT100NeededFor0 > 0)
{
iFoodYieldValue *= 8;
}
else
{
iFoodYieldValue /= 2;
}
}
// If our surplus is not at least 2, really emphasize food plots
else if(!bAvoidGrowth)
{
int iFoodT100NeededFor2 = 200 - iExcessFoodTimes100;
if(iFoodT100NeededFor2 > 0)
{
iFoodYieldValue *= 8;
}
else if (eFocus != CITY_AI_FOCUS_TYPE_FOOD)
{
iFoodYieldValue /= 2;
}
}
}
if((eFocus == NO_CITY_AI_FOCUS_TYPE || eFocus == CITY_AI_FOCUS_TYPE_PROD_GROWTH || eFocus == CITY_AI_FOCUS_TYPE_GOLD_GROWTH) && !bAvoidGrowth && m_pCity->getPopulation() < 5)
{
iFoodYieldValue *= 4;
}
iValue += iFoodYieldValue;
iValue += iProductionYieldValue;
iValue += iGoldYieldValue;
iValue += iScienceYieldValue;
iValue += iCultureYieldValue;
iValue += iFaithYieldValue;
return iValue;
} Source: Which indeed seems on first glance to do exactly that: get food tiles when we're starving, and otherwise decided based on the focus that is set in the city |
Oooh, had forgotten about the Avoid Growth feature. Add that to the TODO list |
Civ 5 (and others in the series) gave the option to focus all production via population and specialists towards one metric. Either maximize Food, Production, Gold, or Science. And obviously revert to Balanced
Would be a nice feature to have.
Could also include UI to handle locking tiles as well (and unlock all tiles), and ideally locking Specialists too.
The text was updated successfully, but these errors were encountered: