fix: add costH as a field

This commit is contained in:
Assasinnys 2020-05-10 02:22:43 +03:00
parent d66058daa8
commit a7af2546dc
41 changed files with 13 additions and 5 deletions

7
.idea/dictionaries/Shepord.xml generated Normal file
View File

@ -0,0 +1,7 @@
<component name="ProjectDictionaryState">
<dictionary name="Shepord">
<words>
<w>coords</w>
</words>
</dictionary>
</component>

View File

@ -1,2 +1,2 @@
37
19
39
21

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
}