Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settling Suggestion Improvements #12781

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ object CityLocationTileRanker {
* Returns a hashmap of tiles to their ranking plus the a the highest value tile and its value
*/
fun getBestTilesToFoundCity(unit: MapUnit, distanceToSearch: Int? = null, minimumValue: Float): BestTilesToFoundCity {
val range = if (distanceToSearch != null) distanceToSearch else {
val distanceModifier = 3f // percentage penalty per aerial distance from unit (Settler)
val range = if (distanceToSearch != null) distanceToSearch else {
val distanceFromHome = if (unit.civ.cities.isEmpty()) 0
else unit.civ.cities.minOf { it.getCenterTile().aerialDistanceTo(unit.getTile()) }
(8 - distanceFromHome).coerceIn(1, 5) // Restrict vision when far from home to avoid death marches
Expand All @@ -43,7 +44,9 @@ object CityLocationTileRanker {

val possibleTileLocationsWithRank = possibleCityLocations
.map {
val tileValue = rankTileToSettle(it, unit.civ, nearbyCities, baseTileMap, uniqueCache)
var tileValue = rankTileToSettle(it, unit.civ, nearbyCities, baseTileMap, uniqueCache)
val distanceScore = (unit.currentTile.aerialDistanceTo(it) * distanceModifier).coerceIn(0f, 99f)
tileValue *= (100 - distanceScore) / 100
if (tileValue >= minimumValue)
bestTilesToFoundCity.tileRankMap[it] = tileValue

Expand Down Expand Up @@ -90,7 +93,7 @@ object CityLocationTileRanker {
val onCoast = newCityTile.isCoastalTile()
val onHill = newCityTile.isHill()
val isNextToMountain = newCityTile.isAdjacentTo("Mountain")
// Only count a luxary resource that we don't have yet as unique once
// Only count a luxury resource that we don't have yet as unique once
val newUniqueLuxuryResources = HashSet<String>()

if (onCoast) tileValue += 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ object WorldMapTileUpdater {
// Highlight best tiles for city founding
if (unit.hasUnique(UniqueType.FoundCity)
&& UncivGame.Current.settings.showSettlersSuggestedCityLocations) {
CityLocationTileRanker.getBestTilesToFoundCity(unit, minimumValue = 50f).tileRankMap.asSequence()
CityLocationTileRanker.getBestTilesToFoundCity(unit, 5, minimumValue = 50f).tileRankMap.asSequence()
.filter { it.key.isExplored(unit.civ) }.sortedByDescending { it.value }.take(3).forEach {
tileGroups[it.key]!!.layerOverlay.showGoodCityLocationIndicator()
}
Expand Down
Loading