refactor: change func findStarPointWithMinCost

This commit is contained in:
Assasinnys committed 2020-05-10 02:12:41 +03:00
1 parent 670e833120
commit d66058daa8
71 files changed
+8 -17

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,2 +1,2 @@
21
4
37
19
Binary file not shown.
+3 -7
View File
@@ -74,14 +74,10 @@ class AStarMain(private val startSystem: String, private val finishSystem: Strin
}
private fun findStarPointWithMinCost(): StarPoint {
var nextStarPoint = openedList[0]
openedList.forEach { point ->
when {
// point.isNeutronStar -> return point
point.costF < nextStarPoint.costF -> nextStarPoint = point
}
return openedList.minBy { starPoint -> starPoint.costF }!!.also { nextStarPoint ->
println("Min cost star point: G = ${nextStarPoint.costG}, F = ${nextStarPoint.costF}, " +
"dist = ${nextStarPoint.distance}, start = ${nextStarPoint.previousStarPoint == startStarPoint}")
}
return nextStarPoint
}
private fun findNeighbours(starPoint: StarPoint) {
@@ -69,15 +69,10 @@ class AStarMainFile {
}
private fun findStarPointWithMinCost(): StarPoint {
var nextStarPoint = openedList[0]
openedList.forEach { point ->
when {
// point.isNeutronStar -> return point
point.costF < nextStarPoint.costF -> nextStarPoint = point
}
return openedList.minBy { starPoint -> starPoint.costF }!!.also { nextStarPoint ->
println("Min cost star point: G = ${nextStarPoint.costG}, F = ${nextStarPoint.costF}, " +
"dist = ${nextStarPoint.distance}, start = ${nextStarPoint.previousStarPoint == startStarPoint}")
}
println("Min cost star point: G = ${nextStarPoint.costG}, F = ${nextStarPoint.costF}, dist = ${nextStarPoint.distance}, start = ${nextStarPoint.previousStarPoint == startStarPoint}")
return nextStarPoint
}
private fun findNeighbours(starPoint: StarPoint) {