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

Feature request: AIs sometimes have difficulty with settler + escort vs. barbarians for up to three eras(!) #12063

Open
2 tasks done
PathosEthosLogos opened this issue Aug 4, 2024 · 5 comments
Labels

Comments

@PathosEthosLogos
Copy link

PathosEthosLogos commented Aug 4, 2024

Before creating

  • This is NOT a gameplay feature from Civ VI, BNW, or outside - see Roadmap
  • This is NOT a gameplay feature from Vanilla Civ V or from G&K - If so, it should be a comment in Missing features from Civ V - G&K #4697

Problem Description

I'm still trying to pinpoint more precisely what the conditions are, but basically, when there are barbarians on the map, some AIs get stuck, continuously trying to settle on the same spot or similar direction. However, they are unable to due to barbarians aggressions. When there are few barbarian camps that can converge on to the AI's intended target settlement location, then it is likely that the AI will fail to settle for three eras (longest I've seen survive before they're dominated in deity).

Related Issue Links

No response

Desired Solution

Escorting AI might need a boost with extra army, or only settle after barbarian camps are killed (doesn't have to be all cleared in the area, but at least halved or something)

Alternative Approaches

Settlers could have two or three options and select the next best option when failed twice in a row.

Barbarian camps nearby could deduct 'settlement score' in those tiles.

Additional Context

No response

@PathosEthosLogos
Copy link
Author

I must add that this is especially problematic if the escort unit is a siege unit. They just take hits instead of siege + attack, and maybe let the settler wait a bit or run back to base alone if very near.

@tuvus
Copy link
Collaborator

tuvus commented Aug 7, 2024

Yeah, this is a big problem that we are seeing. The fix isn't very simple however. The AI generally lacks vision of barbarians until it is too late. It is also hard for the AI to remember anything about barbarians.

I did investigate a little into the AI try to protect it's civilian units more but it won't be an easy fix. It also doesn't help that the AI has extra happiness and tries to settle as much as it can.

@yairm210
Copy link
Owner

yairm210 commented Aug 7, 2024

If this is a big problem, I'm okay with allowing the AI to "cheat" and know about barbs it shouldn't know about, to make better choices

@PathosEthosLogos
Copy link
Author

If this is a big problem, I'm okay with allowing the AI to "cheat" and know about barbs it shouldn't know about, to make better choices

Interesting solution! But yes, I would say it's one of the biggest problems at the moment.

One extra tile-distance vs. barbarians could be the solution I think. This means that the vision should not be shown on the UI (for the spectator) and it should not reveal the tile (its characteristics/resources).

@yairm210
Copy link
Owner

Possible solution as patch - "don't enter any tile that enemies can enter":

Index: core/src/com/unciv/logic/automation/unit/CityLocationTileRanker.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/src/com/unciv/logic/automation/unit/CityLocationTileRanker.kt b/core/src/com/unciv/logic/automation/unit/CityLocationTileRanker.kt
--- a/core/src/com/unciv/logic/automation/unit/CityLocationTileRanker.kt	(revision e8565b0b6f868c9559380c29919e8ae7a785c654)
+++ b/core/src/com/unciv/logic/automation/unit/CityLocationTileRanker.kt	(date 1724526102545)
@@ -31,9 +31,17 @@
         }
         val nearbyCities = unit.civ.gameInfo.getCities()
             .filter { it.getCenterTile().aerialDistanceTo(unit.getTile()) <= 7 + range }
+        
+        val nearbyEnemies = unit.currentTile.getTilesInDistance(range*2)
+            .mapNotNull { it.militaryUnit }
+            .filter { it.civ.isAtWarWith(unit.civ) }
+        
+        val tilesEnemiesCanEnter = nearbyEnemies.map { it.movement.getDistanceToTiles() }
+            .flatMap { it.values }.map { it.tile }.toSet()
 
         val uniques = unit.getMatchingUniques(UniqueType.FoundCity)
         val possibleCityLocations = unit.getTile().getTilesInDistance(range)
+            .filterNot { it in tilesEnemiesCanEnter }
             // Filter out tiles that we can't actually found on
             .filter { tile -> uniques.any { it.conditionalsApply(StateForConditionals(unit = unit, tile = tile)) } }
             .filter { canSettleTile(it, unit.civ, nearbyCities) && (unit.getTile() == it || unit.movement.canMoveTo(it)) }

If we have a military escort this might not be the best solution though.
Do you have an example game?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants