mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 07:17:50 +07:00
AI units now go out and explore unseen areas
This commit is contained in:
BIN
android/ImagesToNotAddToGame/Feature graphic.png
Normal file
BIN
android/ImagesToNotAddToGame/Feature graphic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 538 KiB |
BIN
android/ImagesToNotAddToGame/Promo graphic.png
Normal file
BIN
android/ImagesToNotAddToGame/Promo graphic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 538 KiB |
@ -21,8 +21,8 @@ android {
|
||||
applicationId "com.unciv.game"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 26
|
||||
versionCode 137
|
||||
versionName "2.8.5"
|
||||
versionCode 138
|
||||
versionName "2.8.6"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
@ -66,7 +66,7 @@ class UnitAutomation{
|
||||
if (tryHeadTowardsEnemyCity(unit)) return
|
||||
|
||||
// else, go to a random space
|
||||
randomWalk(unit,unitDistanceToTiles)
|
||||
explore(unit,unitDistanceToTiles)
|
||||
// if both failed, then... there aren't any reachable tiles. Which is possible.
|
||||
}
|
||||
|
||||
@ -259,8 +259,15 @@ class UnitAutomation{
|
||||
return false
|
||||
}
|
||||
|
||||
private fun randomWalk(unit: MapUnit, unitDistanceToTiles: HashMap<TileInfo, Float>) {
|
||||
val reachableTiles = unitDistanceToTiles
|
||||
private fun explore(unit: MapUnit, unitDistanceToTiles: HashMap<TileInfo, Float>) {
|
||||
for(tile in unit.currentTile.getTilesInDistance(5))
|
||||
if(unit.canMoveTo(tile) && tile.position !in unit.civInfo.exploredTiles
|
||||
&& unit.movementAlgs().canReach(tile)){
|
||||
unit.movementAlgs().headTowards(tile)
|
||||
return
|
||||
}
|
||||
|
||||
val reachableTiles= unitDistanceToTiles
|
||||
.filter { unit.canMoveTo(it.key) }
|
||||
val reachableTilesMaxWalkingDistance = reachableTiles.filter { it.value == unit.currentMovement }
|
||||
if (reachableTilesMaxWalkingDistance.any()) unit.moveToTile(reachableTilesMaxWalkingDistance.toList().getRandom().first)
|
||||
@ -296,7 +303,7 @@ class UnitAutomation{
|
||||
|
||||
if(bestCityLocation==null) // We got a badass over here, all tiles within 5 are taken? Screw it, random walk.
|
||||
{
|
||||
randomWalk(unit, unit.getDistanceToTiles())
|
||||
explore(unit, unit.getDistanceToTiles())
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,8 @@ class CityStats {
|
||||
val newTiles = tilesToCheck
|
||||
.flatMap { it.neighbors }.distinct()
|
||||
.filter {
|
||||
!tilesReached.contains(it) && !tilesToCheck.contains(it)
|
||||
!tilesReached.contains(it)
|
||||
&& !tilesToCheck.contains(it)
|
||||
&& (roadType !== RoadStatus.Road || it.roadStatus !== RoadStatus.None)
|
||||
&& (roadType !== RoadStatus.Railroad || it.roadStatus === roadType)
|
||||
}
|
||||
|
Reference in New Issue
Block a user