mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 15:27:50 +07:00
Improved AI city location picking
Done by ignoring tiles already belonging to another civ / within work range of another city
This commit is contained in:
@ -42,10 +42,7 @@ object CityLocationTileRanker {
|
||||
|
||||
val distanceFromHome = if (unit.civ.cities.isEmpty()) 0
|
||||
else unit.civ.cities.minOf { it.getCenterTile().aerialDistanceTo(unit.getTile()) }
|
||||
val range = (8 - distanceFromHome).coerceIn(
|
||||
1,
|
||||
5
|
||||
) // Restrict vision when far from home to avoid death marches
|
||||
val range = (8 - distanceFromHome).coerceIn(1, 5) // Restrict vision when far from home to avoid death marches
|
||||
|
||||
val possibleCityLocations = unit.getTile().getTilesInDistance(range)
|
||||
.filter { canUseTileForRanking(it, unit.civ) }
|
||||
@ -60,15 +57,14 @@ object CityLocationTileRanker {
|
||||
|
||||
return possibleCityLocations
|
||||
.map {
|
||||
Pair(
|
||||
it,
|
||||
it to
|
||||
rankTileAsCityCenterWithCachedValues(
|
||||
it,
|
||||
nearbyTileRankings,
|
||||
luxuryResourcesInCivArea,
|
||||
unit.civ
|
||||
),
|
||||
)
|
||||
|
||||
}
|
||||
.sortedByDescending { it.second }
|
||||
}
|
||||
@ -88,8 +84,10 @@ object CityLocationTileRanker {
|
||||
tile: Tile,
|
||||
civ: Civilization
|
||||
) =
|
||||
// The AI is allowed to cheat and act like it knows the whole map.
|
||||
tile.isExplored(civ) || civ.isAI()
|
||||
|
||||
(tile.isExplored(civ) || civ.isAI()) // The AI is allowed to cheat and act like it knows the whole map.
|
||||
&& (tile.getOwner() == null ||
|
||||
tile.getOwner() == civ && tile.getTilesInDistance(3).none { it.isCityCenter() })
|
||||
|
||||
private fun getNearbyTileRankings(
|
||||
tile: Tile,
|
||||
|
@ -127,9 +127,9 @@ These shapes are used all over Unciv and can be replaced to make a lot of UI ele
|
||||
| WorldScreen/TopBar/ | ResourceTable | null | |
|
||||
| WorldScreen/TopBar/ | RightAttachment | roundedEdgeRectangle | |
|
||||
| WorldScreen/TopBar/ | StatsTable | null | |
|
||||
| WorldScreenMusicPopup/TrackList/ | Down", tintColor = skin.getColor("positive | null | |
|
||||
| WorldScreenMusicPopup/TrackList/ | Over", tintColor = skin.getColor("highlight | null | |
|
||||
| WorldScreenMusicPopup/TrackList/ | Up", tintColor = skin.getColor("color | null | |
|
||||
| WorldScreenMusicPopup/TrackList/ | Down | null | |
|
||||
| WorldScreenMusicPopup/TrackList/ | Over | null | |
|
||||
| WorldScreenMusicPopup/TrackList/ | Up | null | |
|
||||
<!--- DO NOT REMOVE OR MODIFY THIS LINE UI_ELEMENT_TABLE_REGION_END -->
|
||||
|
||||
## SkinConfig
|
||||
|
Reference in New Issue
Block a user