mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-15 10:18:26 +07:00
Rudimentary AI control over goldPercentConvertedToScience (#6221)
This commit is contained in:
@ -60,7 +60,7 @@ object NextTurnAutomation {
|
||||
bullyCityStates(civInfo)
|
||||
}
|
||||
automateUnits(civInfo) // this is the most expensive part
|
||||
|
||||
|
||||
if (civInfo.isMajorCiv()) {
|
||||
// Can only be done now, as the prophet first has to decide to found/enhance a religion
|
||||
chooseReligiousBeliefs(civInfo)
|
||||
@ -71,6 +71,21 @@ object NextTurnAutomation {
|
||||
tryVoteForDiplomaticVictory(civInfo)
|
||||
}
|
||||
|
||||
fun automateGoldToSciencePercentage(civInfo: CivilizationInfo) {
|
||||
// Don't let the AI run blindly with the default convert-gold-to-science ratio if that option is enabled
|
||||
val estimatedIncome = civInfo.statsForNextTurn.gold.toInt()
|
||||
val projectedGold = civInfo.gold + estimatedIncome
|
||||
// TODO: some cleverness, this is just wild guessing.
|
||||
val pissPoor = civInfo.tech.era.baseUnitBuyCost
|
||||
val stinkingRich = civInfo.tech.era.startingGold * 10 + civInfo.cities.size * 2 * pissPoor
|
||||
val maxPercent = 0.8f
|
||||
civInfo.tech.goldPercentConvertedToScience = when {
|
||||
civInfo.gold <= 0 -> 0f
|
||||
projectedGold <= pissPoor -> 0f
|
||||
else -> ((projectedGold - pissPoor) * maxPercent / stinkingRich).coerceAtMost(maxPercent)
|
||||
}
|
||||
}
|
||||
|
||||
private fun respondToTradeRequests(civInfo: CivilizationInfo) {
|
||||
for (tradeRequest in civInfo.tradeRequests.toList()) {
|
||||
val otherCiv = civInfo.gameInfo.getCivilization(tradeRequest.requestingCiv)
|
||||
|
@ -5,6 +5,7 @@ import com.unciv.Constants
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.GameInfo
|
||||
import com.unciv.logic.UncivShowableException
|
||||
import com.unciv.logic.automation.NextTurnAutomation
|
||||
import com.unciv.logic.automation.WorkerAutomation
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.civilization.RuinsManager.RuinsManager
|
||||
@ -792,6 +793,10 @@ class CivilizationInfo {
|
||||
attacksSinceTurnStart.clear()
|
||||
updateStatsForNextTurn() // for things that change when turn passes e.g. golden age, city state influence
|
||||
|
||||
// Do this after updateStatsForNextTurn but before cities.startTurn
|
||||
if (playerType == PlayerType.AI && gameInfo.ruleSet.modOptions.uniques.contains(ModOptionsConstants.convertGoldToScience))
|
||||
NextTurnAutomation.automateGoldToSciencePercentage(this)
|
||||
|
||||
// Generate great people at the start of the turn,
|
||||
// so they won't be generated out in the open and vulnerable to enemy attacks before you can control them
|
||||
if (cities.isNotEmpty()) { //if no city available, addGreatPerson will throw exception
|
||||
|
Reference in New Issue
Block a user