Hide invisible resources for AI (#12772)

* Update CityLocationTileRanker.kt

* Update WorkerAutomation.kt
This commit is contained in:
EmperorPinguin 2025-01-11 19:01:44 +01:00 committed by GitHub
parent 534850fd90
commit e3e2831f9a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -103,8 +103,8 @@ object CityLocationTileRanker {
// We want to found the city on an oasis because it can't be improved otherwise // We want to found the city on an oasis because it can't be improved otherwise
if (newCityTile.terrainHasUnique(UniqueType.Unbuildable)) tileValue += 3 if (newCityTile.terrainHasUnique(UniqueType.Unbuildable)) tileValue += 3
// If we build the city on a resource tile, then we can't build any special improvements on it // If we build the city on a resource tile, then we can't build any special improvements on it
if (newCityTile.resource != null) tileValue -= 4 if (newCityTile.hasViewableResource(civ)) tileValue -= 4
if (newCityTile.resource != null && newCityTile.tileResource.resourceType == ResourceType.Bonus) tileValue -= 8 if (newCityTile.hasViewableResource(civ) && newCityTile.tileResource.resourceType == ResourceType.Bonus) tileValue -= 8
// Settling on bonus resources tends to waste a food // Settling on bonus resources tends to waste a food
// Settling on luxuries generally speeds up our game, and settling on strategics as well, as the AI cheats and can see them. // Settling on luxuries generally speeds up our game, and settling on strategics as well, as the AI cheats and can see them.
@ -155,7 +155,7 @@ object CityLocationTileRanker {
// Don't settle near but not on the coast // Don't settle near but not on the coast
if (rankTile.isCoastalTile() && !onCoast) locationSpecificTileValue -= 2 if (rankTile.isCoastalTile() && !onCoast) locationSpecificTileValue -= 2
// Check if there are any new unique luxury resources // Check if there are any new unique luxury resources
if (rankTile.resource != null && rankTile.tileResource.resourceType == ResourceType.Luxury if (rankTile.hasViewableResource(civ) && rankTile.tileResource.resourceType == ResourceType.Luxury
&& !(civ.hasResource(rankTile.resource!!) || newUniqueLuxuryResources.contains(rankTile.resource))) { && !(civ.hasResource(rankTile.resource!!) || newUniqueLuxuryResources.contains(rankTile.resource))) {
locationSpecificTileValue += 10 locationSpecificTileValue += 10
newUniqueLuxuryResources.add(rankTile.resource!!) newUniqueLuxuryResources.add(rankTile.resource!!)
@ -167,7 +167,7 @@ object CityLocationTileRanker {
var rankTileValue = Automation.rankStatsValue(rankTile.stats.getTileStats(null, civ, uniqueCache), civ) var rankTileValue = Automation.rankStatsValue(rankTile.stats.getTileStats(null, civ, uniqueCache), civ)
if (rankTile.resource != null) { if (rankTile.hasViewableResource(civ)) {
rankTileValue += when (rankTile.tileResource.resourceType) { rankTileValue += when (rankTile.tileResource.resourceType) {
ResourceType.Bonus -> 2f ResourceType.Bonus -> 2f
ResourceType.Strategic -> 1.2f * rankTile.resourceAmount ResourceType.Strategic -> 1.2f * rankTile.resourceAmount

View File

@ -450,7 +450,7 @@ class WorkerAutomation(
val stats = tile.stats.getStatDiffForImprovement(improvement, civInfo, tile.getCity(), localUniqueCache, currentTileStats) val stats = tile.stats.getStatDiffForImprovement(improvement, civInfo, tile.getCity(), localUniqueCache, currentTileStats)
var isResourceImprovedByNewImprovement = tile.resource != null && tile.tileResource.isImprovedBy(improvementName) var isResourceImprovedByNewImprovement = tile.hasViewableResource(civInfo) && tile.tileResource.isImprovedBy(improvementName)
if (improvementName.startsWith(Constants.remove)) { if (improvementName.startsWith(Constants.remove)) {
// We need to look beyond what we are doing right now and at the final improvement that will be on this tile // We need to look beyond what we are doing right now and at the final improvement that will be on this tile