fix: add costH as a field

This commit is contained in:
Assasinnys committed 2020-05-10 02:22:43 +03:00
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.
+7
View File
@@ -0,0 +1,7 @@
<component name="ProjectDictionaryState">
<dictionary name="Shepord">
<words>
<w>coords</w>
</words>
</dictionary>
</component>
Binary file not shown.
@@ -1,2 +1,2 @@
37
19
39
21
Binary file not shown.
+4 -3
View File
@@ -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
}