mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 15:01:09 -04:00
Culture-oriented AI much more predisposed to peace agreements
This commit is contained in:
parent
b8e5b34489
commit
00153ab456
@ -21,8 +21,8 @@ android {
|
|||||||
applicationId "com.unciv.app"
|
applicationId "com.unciv.app"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 256
|
versionCode 257
|
||||||
versionName "2.17.5"
|
versionName "2.17.6"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Had to add this crap for Travis to build, it wanted to sign the app
|
// Had to add this crap for Travis to build, it wanted to sign the app
|
||||||
|
@ -233,18 +233,18 @@ class NextTurnAutomation{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun offerPeaceTreaty(civInfo: CivilizationInfo) {
|
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)
|
val ourCombatStrength = Automation().evaluteCombatStrength(civInfo)
|
||||||
if (civInfo.isAtWar()) { //evaluate peace
|
val enemiesCiv = civInfo.diplomacy.filter { it.value.diplomaticStatus == DiplomaticStatus.War }
|
||||||
val enemiesCiv = civInfo.diplomacy.filter{ it.value.diplomaticStatus == DiplomaticStatus.War }
|
.map { it.value.otherCiv() }
|
||||||
.map{ it.value.otherCiv() }
|
.filterNot { it == civInfo || it.isBarbarianCivilization() || it.cities.isEmpty() }
|
||||||
.filterNot{ it == civInfo || it.isBarbarianCivilization() || it.cities.isEmpty() }
|
|
||||||
.filter { !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedPeace) }
|
.filter { !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedPeace) }
|
||||||
|
|
||||||
for (enemy in enemiesCiv) {
|
for (enemy in enemiesCiv) {
|
||||||
val enemiesStrength = Automation().evaluteCombatStrength(enemy)
|
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.
|
continue //We're losing, but can still fight. Refuse peace.
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,19 +254,19 @@ class NextTurnAutomation{
|
|||||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||||
|
|
||||||
var moneyWeNeedToPay = -TradeEvaluation().evaluatePeaceCostForThem(civInfo,enemy)
|
var moneyWeNeedToPay = -TradeEvaluation().evaluatePeaceCostForThem(civInfo, enemy)
|
||||||
if(moneyWeNeedToPay>0) {
|
if (moneyWeNeedToPay > 0) {
|
||||||
if (moneyWeNeedToPay > civInfo.gold && civInfo.gold > 0) { // we need to make up for this somehow...
|
if (moneyWeNeedToPay > civInfo.gold && civInfo.gold > 0) { // we need to make up for this somehow...
|
||||||
moneyWeNeedToPay = civInfo.gold
|
moneyWeNeedToPay = civInfo.gold
|
||||||
}
|
}
|
||||||
if (civInfo.gold > 0) tradeLogic.currentTrade.ourOffers.add(TradeOffer("Gold".tr(), TradeType.Gold, 0, moneyWeNeedToPay))
|
if (civInfo.gold > 0) tradeLogic.currentTrade.ourOffers.add(TradeOffer("Gold".tr(), TradeType.Gold, 0, moneyWeNeedToPay))
|
||||||
}
|
}
|
||||||
|
|
||||||
if(enemy.isPlayerCivilization())
|
if (enemy.isPlayerCivilization())
|
||||||
enemy.tradeRequests.add(TradeRequest(civInfo.civName,tradeLogic.currentTrade.reverse()))
|
enemy.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
||||||
|
|
||||||
else {
|
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) {
|
&& enemy.happiness > 0) {
|
||||||
continue //enemy AI has too large army and happiness. It continues to fight for profit.
|
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) {
|
private fun updateDiplomaticRelationship(civInfo: CivilizationInfo) {
|
||||||
// Check if city-state invaded by other civs
|
// Check if city-state invaded by other civs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user