mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-12 19:10:12 +07:00
When settlers have no viable spots within 5 tiles, they random walk to edges of walking ability
This commit is contained in:
parent
75b6a59ef4
commit
d3799a0c64
@ -21,8 +21,8 @@ android {
|
||||
applicationId "com.unciv.game"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 26
|
||||
versionCode 57
|
||||
versionName "2.1.7"
|
||||
versionCode 58
|
||||
versionName "2.1.8"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
@ -133,15 +133,16 @@ class UnitAutomation{
|
||||
val nearbyTileRankings = unit.getTile().getTilesInDistance(7)
|
||||
.associateBy ( {it},{ Automation().rankTile(it,unit.civInfo) })
|
||||
|
||||
var possibleTiles = unit.getTile().getTilesInDistance(5)
|
||||
val possibleTiles = unit.getTile().getTilesInDistance(5)
|
||||
.minus(tilesNearCities)
|
||||
|
||||
if(possibleTiles.isEmpty()) // We got a badass over here, all tiles within 5 are taken? SEARCH EVERYWHERE
|
||||
possibleTiles = unit.civInfo.getViewableTiles()
|
||||
.minus(tilesNearCities)
|
||||
|
||||
if(possibleTiles.isEmpty())// STILL? Practically impossibru but this may prevent a crash
|
||||
return // todo: add random walk?
|
||||
if(possibleTiles.isEmpty()) // We got a badass over here, all tiles within 5 are taken? Screw it, random walk.
|
||||
{
|
||||
unit.moveToTile(unit.getDistanceToTiles()
|
||||
.filter { it.key.unit == null && it.value==unit.currentMovement } // at edge of walking distance
|
||||
.toList().getRandom().first)
|
||||
return
|
||||
}
|
||||
|
||||
val bestCityLocation = possibleTiles
|
||||
.maxBy { rankTileAsCityCenter(it, nearbyTileRankings) }!!
|
||||
|
Loading…
Reference in New Issue
Block a user