mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-14 17:59:11 +07:00
Rebase and commit (#12662)
This commit is contained in:
@ -46,7 +46,34 @@ object Automation {
|
|||||||
return rank
|
return rank
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// More complicated logic to properly weigh Food vs other Stats (esp Production)
|
||||||
|
private fun getFoodModWeight(city: City, surplusFood: Float): Float {
|
||||||
|
val speed = city.civ.gameInfo.speed.modifier
|
||||||
|
// Zero out Growth if close to Unhappiness limit
|
||||||
|
if (city.civ.getHappiness() < -8)
|
||||||
|
return 0f
|
||||||
|
if (city.civ.isAI()) {
|
||||||
|
// When Happy, 2 production is better than 1 growth,
|
||||||
|
// but setting such by default worsens AI civ citizen assignment,
|
||||||
|
// probably due to badly configured personalities not properly weighing food vs non-food yields
|
||||||
|
if (city.population.population < 5)
|
||||||
|
return 2f
|
||||||
|
if (surplusFood > city.population.getFoodToNextPopulation() / (10 * speed))
|
||||||
|
return 0.75f // get Growth just under Production
|
||||||
|
return 1.5f
|
||||||
|
}
|
||||||
|
// Human weights. May be different since AI Happiness is always "easier"
|
||||||
|
// Only apply these for Default to not interfere with Focus weights
|
||||||
|
if (city.getCityFocus() == CityFocus.NoFocus) {
|
||||||
|
if (city.population.population < 5)
|
||||||
|
return 2f
|
||||||
|
if (surplusFood > city.population.getFoodToNextPopulation() / (10 * speed))
|
||||||
|
return 0.75f // get Growth just under Production
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1f
|
||||||
|
}
|
||||||
|
|
||||||
fun rankStatsForCityWork(stats: Stats, city: City, areWeRankingSpecialist: Boolean, localUniqueCache: LocalUniqueCache): Float {
|
fun rankStatsForCityWork(stats: Stats, city: City, areWeRankingSpecialist: Boolean, localUniqueCache: LocalUniqueCache): Float {
|
||||||
val cityAIFocus = city.getCityFocus()
|
val cityAIFocus = city.getCityFocus()
|
||||||
val yieldStats = stats.clone()
|
val yieldStats = stats.clone()
|
||||||
@ -116,16 +143,8 @@ object Automation {
|
|||||||
newGrowthFood += growthFood / 4
|
newGrowthFood += growthFood / 4
|
||||||
}
|
}
|
||||||
newGrowthFood = newGrowthFood.coerceAtLeast(0f) // floor to 0 for safety
|
newGrowthFood = newGrowthFood.coerceAtLeast(0f) // floor to 0 for safety
|
||||||
|
|
||||||
// When Happy, 2 production is better than 1 growth,
|
yieldStats.food += newGrowthFood * foodBaseWeight * getFoodModWeight(city, surplusFood)
|
||||||
// but setting such by default worsens AI civ citizen assignment,
|
|
||||||
// probably due to badly configured personalities not properly weighing food vs non-food yields
|
|
||||||
|
|
||||||
// Zero out Growth if close to Unhappiness limit as well
|
|
||||||
val baseFocusWeight = if (city.civ.getHappiness() < -8) 0 else {
|
|
||||||
if (cityAIFocus in CityFocus.zeroFoodFocuses) 1 else 2
|
|
||||||
}
|
|
||||||
yieldStats.food += newGrowthFood * foodBaseWeight * baseFocusWeight
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (city.population.population < 10) {
|
if (city.population.population < 10) {
|
||||||
|
@ -41,13 +41,15 @@ enum class CityFocus(
|
|||||||
FaithFocus("${Stat.Faith.character}", true, Stat.Faith),
|
FaithFocus("${Stat.Faith.character}", true, Stat.Faith),
|
||||||
GoldGrowthFocus("${Stat.Gold.character} ${Stat.Food.character}", true) {
|
GoldGrowthFocus("${Stat.Gold.character} ${Stat.Food.character}", true) {
|
||||||
override fun getStatMultiplier(stat: Stat) = when (stat) {
|
override fun getStatMultiplier(stat: Stat) = when (stat) {
|
||||||
Stat.Gold, Stat.Food -> 2f
|
Stat.Gold -> 2f
|
||||||
|
Stat.Food -> 1.5f
|
||||||
else -> 1f
|
else -> 1f
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ProductionGrowthFocus("${Stat.Production.character} ${Stat.Food.character}", true) {
|
ProductionGrowthFocus("${Stat.Production.character} ${Stat.Food.character}", true) {
|
||||||
override fun getStatMultiplier(stat: Stat) = when (stat) {
|
override fun getStatMultiplier(stat: Stat) = when (stat) {
|
||||||
Stat.Production, Stat.Food -> 2f
|
Stat.Production -> 2f
|
||||||
|
Stat.Food -> 1.5f
|
||||||
else -> 1f
|
else -> 1f
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user