Sped up FindShortestPath alg
When finding shortest path, we no longer check intermediary tiles for the next step, since they will always have a longer path than the edge tiles (since from there, we need to pass through an edge tile anyway)
This commit is contained in:
parent
26b19271ff
commit
eac8afef75
1 changed files with 2 additions and 2 deletions
|
@ -81,9 +81,9 @@ class UnitMovementAlgorithms(val tileMap: TileMap){
|
|||
|
||||
if(newTilesToCheck.isEmpty()) return emptyList() // there is NO PATH (eg blocked by enemy units)
|
||||
|
||||
tilesToCheck = newTilesToCheck
|
||||
tilesToCheck = newTilesToCheck.filterNot {tile -> tile.neighbors.all{newTilesToCheck.contains(it) || tilesToCheck.contains(it) } }
|
||||
distance++
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue