mirror of
https://github.com/Assasinnys/ED-AStar-Galaxy-Router
synced 2026-11-18 02:52:24 +03:00
fix: add costH as a field
This commit is contained in:
1 parent
d66058daa8
commit
a7af2546dc
41 files changed
+13
-5
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.
Generated
+7
@@ -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.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user