From e3e2831f9ab8c006071f86ff63f63c243292c756 Mon Sep 17 00:00:00 2001 From: EmperorPinguin <99119424+EmperorPinguin@users.noreply.github.com> Date: Sat, 11 Jan 2025 19:01:44 +0100 Subject: [PATCH] Hide invisible resources for AI (#12772) * Update CityLocationTileRanker.kt * Update WorkerAutomation.kt --- .../unciv/logic/automation/unit/CityLocationTileRanker.kt | 8 ++++---- .../com/unciv/logic/automation/unit/WorkerAutomation.kt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/logic/automation/unit/CityLocationTileRanker.kt b/core/src/com/unciv/logic/automation/unit/CityLocationTileRanker.kt index 6f40cd5296..b52659dde1 100644 --- a/core/src/com/unciv/logic/automation/unit/CityLocationTileRanker.kt +++ b/core/src/com/unciv/logic/automation/unit/CityLocationTileRanker.kt @@ -103,8 +103,8 @@ object CityLocationTileRanker { // We want to found the city on an oasis because it can't be improved otherwise 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 (newCityTile.resource != null) tileValue -= 4 - if (newCityTile.resource != null && newCityTile.tileResource.resourceType == ResourceType.Bonus) tileValue -= 8 + if (newCityTile.hasViewableResource(civ)) tileValue -= 4 + if (newCityTile.hasViewableResource(civ) && newCityTile.tileResource.resourceType == ResourceType.Bonus) tileValue -= 8 // 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. @@ -155,7 +155,7 @@ object CityLocationTileRanker { // Don't settle near but not on the coast if (rankTile.isCoastalTile() && !onCoast) locationSpecificTileValue -= 2 // 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))) { locationSpecificTileValue += 10 newUniqueLuxuryResources.add(rankTile.resource!!) @@ -167,7 +167,7 @@ object CityLocationTileRanker { var rankTileValue = Automation.rankStatsValue(rankTile.stats.getTileStats(null, civ, uniqueCache), civ) - if (rankTile.resource != null) { + if (rankTile.hasViewableResource(civ)) { rankTileValue += when (rankTile.tileResource.resourceType) { ResourceType.Bonus -> 2f ResourceType.Strategic -> 1.2f * rankTile.resourceAmount diff --git a/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt b/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt index b6c8e99c8c..37ce4aa011 100644 --- a/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt @@ -450,7 +450,7 @@ class WorkerAutomation( 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)) { // We need to look beyond what we are doing right now and at the final improvement that will be on this tile