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:
yairm210 2018-04-29 13:31:10 +03:00 committed by GitHub
parent 26b19271ff
commit eac8afef75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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++
}
}
}
}