mirror of
https://github.com/Assasinnys/ED-AStar-Galaxy-Router
synced 2025-04-13 06:47:13 +03:00
refactor: change func findStarPointWithMinCost
This commit is contained in:
parent
670e833120
commit
d66058daa8
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.
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.
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.
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.
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.
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.
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
|
37
|
||||||
4
|
19
|
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.
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -74,14 +74,10 @@ class AStarMain(private val startSystem: String, private val finishSystem: Strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun findStarPointWithMinCost(): StarPoint {
|
private fun findStarPointWithMinCost(): StarPoint {
|
||||||
var nextStarPoint = openedList[0]
|
return openedList.minBy { starPoint -> starPoint.costF }!!.also { nextStarPoint ->
|
||||||
openedList.forEach { point ->
|
println("Min cost star point: G = ${nextStarPoint.costG}, F = ${nextStarPoint.costF}, " +
|
||||||
when {
|
"dist = ${nextStarPoint.distance}, start = ${nextStarPoint.previousStarPoint == startStarPoint}")
|
||||||
// point.isNeutronStar -> return point
|
|
||||||
point.costF < nextStarPoint.costF -> nextStarPoint = point
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nextStarPoint
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findNeighbours(starPoint: StarPoint) {
|
private fun findNeighbours(starPoint: StarPoint) {
|
||||||
|
@ -69,15 +69,10 @@ class AStarMainFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun findStarPointWithMinCost(): StarPoint {
|
private fun findStarPointWithMinCost(): StarPoint {
|
||||||
var nextStarPoint = openedList[0]
|
return openedList.minBy { starPoint -> starPoint.costF }!!.also { nextStarPoint ->
|
||||||
openedList.forEach { point ->
|
println("Min cost star point: G = ${nextStarPoint.costG}, F = ${nextStarPoint.costF}, " +
|
||||||
when {
|
"dist = ${nextStarPoint.distance}, start = ${nextStarPoint.previousStarPoint == startStarPoint}")
|
||||||
// point.isNeutronStar -> return point
|
|
||||||
point.costF < nextStarPoint.costF -> nextStarPoint = point
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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) {
|
private fun findNeighbours(starPoint: StarPoint) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user