Minor improvements from GPC

This commit is contained in:
Yair Morgenstern 2022-02-28 19:39:44 +02:00
parent 6bbab8a394
commit 8a6b4de84f
3 changed files with 29 additions and 29 deletions

View File

@ -212,33 +212,33 @@ class WorkerAutomation(
}
while (true) {
for (cityTile in cityTilesToSeek) {
if (bfs.hasReachedTile(cityTile)) { // we have a winner!
val pathToCity = bfs.getPathTo(cityTile)
val roadableTiles = pathToCity.filter { it.roadStatus < bestRoadAvailable }
val tileToConstructRoadOn: TileInfo
if (currentTile in roadableTiles) tileToConstructRoadOn =
currentTile
else {
val reachableTile = roadableTiles
.sortedBy { it.aerialDistanceTo(unit.getTile()) }
.firstOrNull {
unit.movement.canMoveTo(it) && unit.movement.canReach(
it
)
}
?: continue
tileToConstructRoadOn = reachableTile
unit.movement.headTowards(tileToConstructRoadOn)
}
if (unit.currentMovement > 0 && currentTile == tileToConstructRoadOn
&& currentTile.improvementInProgress != bestRoadAvailable.name) {
val improvement = bestRoadAvailable.improvement(ruleSet)!!
tileToConstructRoadOn.startWorkingOnImprovement(improvement, civInfo)
}
if (WorkerAutomationConst.consoleOutput)
println("WorkerAutomation: ${unit.label()} -> connect city ${bfs.startingPoint.getCity()?.name} to ${cityTile.getCity()!!.name} on $tileToConstructRoadOn")
return true
if (!bfs.hasReachedTile(cityTile)) continue
// we have a winner!
val pathToCity = bfs.getPathTo(cityTile)
val roadableTiles = pathToCity.filter { it.roadStatus < bestRoadAvailable }
val tileToConstructRoadOn: TileInfo
if (currentTile in roadableTiles) tileToConstructRoadOn =
currentTile
else {
val reachableTile = roadableTiles
.sortedBy { it.aerialDistanceTo(unit.getTile()) }
.firstOrNull {
unit.movement.canMoveTo(it) && unit.movement.canReach(
it
)
}
?: continue
tileToConstructRoadOn = reachableTile
unit.movement.headTowards(tileToConstructRoadOn)
}
if (unit.currentMovement > 0 && currentTile == tileToConstructRoadOn
&& currentTile.improvementInProgress != bestRoadAvailable.name) {
val improvement = bestRoadAvailable.improvement(ruleSet)!!
tileToConstructRoadOn.startWorkingOnImprovement(improvement, civInfo)
}
if (WorkerAutomationConst.consoleOutput)
println("WorkerAutomation: ${unit.label()} -> connect city ${bfs.startingPoint.getCity()?.name} to ${cityTile.getCity()!!.name} on $tileToConstructRoadOn")
return true
}
if (bfs.hasEnded()) break
bfs.nextStep()

View File

@ -349,7 +349,7 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
if (!requireWholeList && modifiers.values.sum() < -100)
return modifiers
val bullyRange = max(5, civInfo.gameInfo.tileMap.tileMatrix.size / 10) // Longer range for larger maps
val bullyRange = (civInfo.gameInfo.tileMap.tileMatrix.size / 10).coerceIn(5, 10) // Longer range for larger maps
val inRangeTiles = civInfo.getCapital().getCenterTile().getTilesInDistanceRange(1..bullyRange)
val forceNearCity = inRangeTiles
.sumOf { if (it.militaryUnit?.civInfo == demandingCiv)

View File

@ -168,11 +168,11 @@ class DiplomacyManager() {
return otherCiv().getDiplomacyManager(civInfo).relationshipLevel()
if (civInfo.isCityState()) return when {
influence >= 60 && civInfo.getAllyCiv() == otherCivName -> RelationshipLevel.Ally
influence >= 30 -> RelationshipLevel.Friend
influence <= -30 || civInfo.isAtWarWith(otherCiv()) -> RelationshipLevel.Unforgivable
influence < 30 && civInfo.getTributeWillingness(otherCiv()) > 0 -> RelationshipLevel.Afraid
influence < 0 -> RelationshipLevel.Enemy
influence >= 60 && civInfo.getAllyCiv() == otherCivName -> RelationshipLevel.Ally
influence >= 30 -> RelationshipLevel.Friend
else -> RelationshipLevel.Neutral
}