mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-24 06:39:16 +07:00
Resolved #3653 - Settler AI no longer aims for 'really far' tiles
This commit is contained in:
@ -163,15 +163,20 @@ object SpecificUnitAutomation {
|
|||||||
it.isLand && (tileOwner == null || tileOwner == unit.civInfo) // don't allow settler to settle inside other civ's territory
|
it.isLand && (tileOwner == null || tileOwner == unit.civInfo) // don't allow settler to settle inside other civ's territory
|
||||||
&& (unit.currentTile == it || unit.movement.canMoveTo(it))
|
&& (unit.currentTile == it || unit.movement.canMoveTo(it))
|
||||||
&& it !in tilesNearCities
|
&& it !in tilesNearCities
|
||||||
}
|
}.toList()
|
||||||
|
|
||||||
val luxuryResourcesInCivArea = unit.civInfo.cities.asSequence()
|
val luxuryResourcesInCivArea = unit.civInfo.cities.asSequence()
|
||||||
.flatMap { it.getTiles().asSequence() }.filter { it.resource != null }
|
.flatMap { it.getTiles().asSequence() }.filter { it.resource != null }
|
||||||
.map { it.getTileResource() }.filter { it.resourceType == ResourceType.Luxury }
|
.map { it.getTileResource() }.filter { it.resourceType == ResourceType.Luxury }
|
||||||
.distinct()
|
.distinct()
|
||||||
val bestCityLocation: TileInfo? = possibleCityLocations
|
|
||||||
.sortedByDescending { rankTileAsCityCenter(it, nearbyTileRankings, luxuryResourcesInCivArea) }
|
val citiesByRanking= possibleCityLocations
|
||||||
.firstOrNull { unit.movement.canReach(it) }
|
.map { Pair(it, rankTileAsCityCenter(it, nearbyTileRankings, luxuryResourcesInCivArea)) }
|
||||||
|
.sortedByDescending { it.second }.toList()
|
||||||
|
|
||||||
|
// It's possible that we'll see a tile "over the sea" that's better than the tiles close by, but that's not a reason to abandon the close tiles!
|
||||||
|
// Also this lead to some routing problems, see https://github.com/yairm210/Unciv/issues/3653
|
||||||
|
val bestCityLocation: TileInfo? = citiesByRanking.firstOrNull { unit.movement.getShortestPath(it.first).size < 4 }?.first
|
||||||
|
|
||||||
if (bestCityLocation == null) { // We got a badass over here, all tiles within 5 are taken? Screw it, random walk.
|
if (bestCityLocation == null) { // We got a badass over here, all tiles within 5 are taken? Screw it, random walk.
|
||||||
if (UnitAutomation.tryExplore(unit)) return // try to find new areas
|
if (UnitAutomation.tryExplore(unit)) return // try to find new areas
|
||||||
|
@ -21,6 +21,8 @@ class TileInfoTable(private val viewingCiv :CivilizationInfo) : Table(CameraStag
|
|||||||
if (tile != null && (UncivGame.Current.viewEntireMapForDebug || viewingCiv.exploredTiles.contains(tile.position)) ) {
|
if (tile != null && (UncivGame.Current.viewEntireMapForDebug || viewingCiv.exploredTiles.contains(tile.position)) ) {
|
||||||
add(getStatsTable(tile))
|
add(getStatsTable(tile))
|
||||||
add(tile.toString(viewingCiv).toLabel()).colspan(2).pad(10f)
|
add(tile.toString(viewingCiv).toLabel()).colspan(2).pad(10f)
|
||||||
|
// For debug only!
|
||||||
|
add(tile.position.toString().toLabel()).colspan(2).pad(10f)
|
||||||
}
|
}
|
||||||
|
|
||||||
pack()
|
pack()
|
||||||
|
Reference in New Issue
Block a user