mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 10:54:19 -04: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"
|
applicationId "com.unciv.game"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 57
|
versionCode 58
|
||||||
versionName "2.1.7"
|
versionName "2.1.8"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
@ -133,15 +133,16 @@ class UnitAutomation{
|
|||||||
val nearbyTileRankings = unit.getTile().getTilesInDistance(7)
|
val nearbyTileRankings = unit.getTile().getTilesInDistance(7)
|
||||||
.associateBy ( {it},{ Automation().rankTile(it,unit.civInfo) })
|
.associateBy ( {it},{ Automation().rankTile(it,unit.civInfo) })
|
||||||
|
|
||||||
var possibleTiles = unit.getTile().getTilesInDistance(5)
|
val possibleTiles = unit.getTile().getTilesInDistance(5)
|
||||||
.minus(tilesNearCities)
|
.minus(tilesNearCities)
|
||||||
|
|
||||||
if(possibleTiles.isEmpty()) // We got a badass over here, all tiles within 5 are taken? SEARCH EVERYWHERE
|
if(possibleTiles.isEmpty()) // We got a badass over here, all tiles within 5 are taken? Screw it, random walk.
|
||||||
possibleTiles = unit.civInfo.getViewableTiles()
|
{
|
||||||
.minus(tilesNearCities)
|
unit.moveToTile(unit.getDistanceToTiles()
|
||||||
|
.filter { it.key.unit == null && it.value==unit.currentMovement } // at edge of walking distance
|
||||||
if(possibleTiles.isEmpty())// STILL? Practically impossibru but this may prevent a crash
|
.toList().getRandom().first)
|
||||||
return // todo: add random walk?
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val bestCityLocation = possibleTiles
|
val bestCityLocation = possibleTiles
|
||||||
.maxBy { rankTileAsCityCenter(it, nearbyTileRankings) }!!
|
.maxBy { rankTileAsCityCenter(it, nearbyTileRankings) }!!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user