mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:51:30 -04:00
Simplified BFS.getPathTo()
This commit is contained in:
parent
d9942aec7c
commit
0fe3de0d50
@ -40,10 +40,10 @@ class BFS(val startingPoint: TileInfo, val predicate : (TileInfo) -> Boolean){
|
|||||||
path.add(destination)
|
path.add(destination)
|
||||||
var currentNode = destination
|
var currentNode = destination
|
||||||
while(currentNode != startingPoint) {
|
while(currentNode != startingPoint) {
|
||||||
tilesReached[currentNode]?.let {
|
val parent = tilesReached[currentNode]
|
||||||
currentNode = it
|
if (parent == null) return ArrayList()// destination is not in our path
|
||||||
|
currentNode = parent
|
||||||
path.add(currentNode)
|
path.add(currentNode)
|
||||||
} ?: return ArrayList() // destination is not in our path
|
|
||||||
}
|
}
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user