Culture-oriented AI much more predisposed to peace agreements

This commit is contained in:
Yair Morgenstern
2019-06-13 14:38:31 +03:00
parent b8e5b34489
commit 00153ab456
2 changed files with 34 additions and 36 deletions

View File

@ -21,8 +21,8 @@ android {
applicationId "com.unciv.app"
minSdkVersion 14
targetSdkVersion 28
versionCode 256
versionName "2.17.5"
versionCode 257
versionName "2.17.6"
}
// Had to add this crap for Travis to build, it wanted to sign the app

View File

@ -233,10 +233,9 @@ class NextTurnAutomation{
}
private fun offerPeaceTreaty(civInfo: CivilizationInfo) {
if (civInfo.cities.isNotEmpty() && civInfo.diplomacy.isNotEmpty()) {
if (!civInfo.isAtWar() || civInfo.cities.isEmpty() || civInfo.diplomacy.isEmpty()) return
val ourCombatStrength = Automation().evaluteCombatStrength(civInfo)
if (civInfo.isAtWar()) { //evaluate peace
val enemiesCiv = civInfo.diplomacy.filter { it.value.diplomaticStatus == DiplomaticStatus.War }
.map { it.value.otherCiv() }
.filterNot { it == civInfo || it.isBarbarianCivilization() || it.cities.isEmpty() }
@ -244,7 +243,8 @@ class NextTurnAutomation{
for (enemy in enemiesCiv) {
val enemiesStrength = Automation().evaluteCombatStrength(enemy)
if (enemiesStrength < ourCombatStrength * 2) {
if (civInfo.getNation().preferredVictoryType!=VictoryType.Cultural
&& enemiesStrength < ourCombatStrength*2 ) {
continue //We're losing, but can still fight. Refuse peace.
}
@ -264,9 +264,9 @@ class NextTurnAutomation{
if (enemy.isPlayerCivilization())
enemy.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
else {
if (enemy.getCivUnits().filter { !it.type.isCivilian() }.size > enemy.cities.size
if (enemy.getNation().preferredVictoryType!=VictoryType.Cultural
&& enemy.getCivUnits().filter { !it.type.isCivilian() }.size > enemy.cities.size
&& enemy.happiness > 0) {
continue //enemy AI has too large army and happiness. It continues to fight for profit.
}
@ -274,8 +274,6 @@ class NextTurnAutomation{
}
}
}
}
}
private fun updateDiplomaticRelationship(civInfo: CivilizationInfo) {
// Check if city-state invaded by other civs