Update TradeEvaluation.kt (#10713)

This commit is contained in:
MioBestWaifu
2023-12-13 17:36:02 -03:00
committed by GitHub
parent 16893ced68
commit 8b5c358904

View File

@ -338,7 +338,10 @@ class TradeEvaluation {
val percentageAdvantage = absoluteAdvantage / theirCombatStrength.toFloat()
// We don't add the same constraint here. We should not make peace easily if we're
// heavily advantaged.
return (absoluteAdvantage * percentageAdvantage).toInt() * 10
val totalAdvantage = (absoluteAdvantage * percentageAdvantage).toInt() * 10
if(totalAdvantage < 0) //May be a negative number if strength disparity is such that it leads to integer overflow
return 10000 //in that rare case, the AI would accept peace against a defeated foe.
return totalAdvantage
} else {
// This results in huge values for large power imbalances. However, we should not give
// up everything just because there is a big power imbalance. There's a better chance to