mirror of
https://github.com/Assasinnys/ED-AStar-Galaxy-Router
synced 2025-04-12 14:37:13 +03:00
fix: add costH as a field
This commit is contained in:
parent
d66058daa8
commit
a7af2546dc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
7
.idea/dictionaries/Shepord.xml
generated
Normal file
7
.idea/dictionaries/Shepord.xml
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="Shepord">
|
||||
<words>
|
||||
<w>coords</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
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 @@
|
||||
37
|
||||
19
|
||||
39
|
||||
21
|
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.
@ -15,8 +15,9 @@ class StarPoint(
|
||||
finishCoords: Coordinates
|
||||
) {
|
||||
|
||||
val costH: Int = calculateCostH(finishCoords)
|
||||
val costG: Double = calculateCostG(distance)
|
||||
val costF: Double = calculateCostF(finishCoords)
|
||||
val costF: Double = calculateCostF()
|
||||
|
||||
private fun calculateCostG(distance: Double): Double {
|
||||
if (distance == 0.0) return 0.0
|
||||
@ -32,9 +33,9 @@ class StarPoint(
|
||||
return previousCostG.plus(costGForStarPoint)
|
||||
}
|
||||
|
||||
private fun calculateCostF(finishCoords: Coordinates): Double {
|
||||
private fun calculateCostF(): Double {
|
||||
return if (previousStarPoint != null) {
|
||||
costG.plus(calculateCostH(finishCoords))
|
||||
costG.plus(costH)
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user