decrease cost of straight vertical and straight horizontal paths compared to diagonal ones, to make it look like enemy is travelling a more coherent path
This commit is contained in:
@@ -157,7 +157,10 @@ struct
|
|||||||
val {y = py, ...} = currentPlat
|
val {y = py, ...} = currentPlat
|
||||||
val {y = cy, ...} = foldPlat
|
val {y = cy, ...} = foldPlat
|
||||||
val dist = abs (py - cy)
|
val dist = abs (py - cy)
|
||||||
val dist = dist + distSoFar
|
|
||||||
|
(* divide by 2 so that we generally "prefer" straight vertical paths
|
||||||
|
* over diagonal ones, even if actual distance is longer *)
|
||||||
|
val dist = (dist + distSoFar) div 2
|
||||||
in
|
in
|
||||||
insertIfNotExistsOrShorter
|
insertIfNotExistsOrShorter
|
||||||
(dist, eKeys, eVals, foldPlatID, q, curPlatID)
|
(dist, eKeys, eVals, foldPlatID, q, curPlatID)
|
||||||
@@ -186,7 +189,9 @@ struct
|
|||||||
val min = Int.min (d1, d2)
|
val min = Int.min (d1, d2)
|
||||||
val min = Int.min (min, d3)
|
val min = Int.min (min, d3)
|
||||||
in
|
in
|
||||||
Int.min (min, d4)
|
(* divide by 2 so we prefer straight horizontal paths over
|
||||||
|
* diagonal ones by giving horizontal ones a lower cost *)
|
||||||
|
(Int.min (min, d4) + distSoFar) div 2
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
@@ -216,9 +221,8 @@ struct
|
|||||||
val dg = Real.fromInt hypsq
|
val dg = Real.fromInt hypsq
|
||||||
val dg = Math.sqrt dg
|
val dg = Math.sqrt dg
|
||||||
in
|
in
|
||||||
Real.toInt IEEEReal.TO_NEAREST dg
|
Real.toInt IEEEReal.TO_NEAREST dg + distSoFar
|
||||||
end
|
end
|
||||||
val dist = dist + distSoFar
|
|
||||||
in
|
in
|
||||||
insertIfNotExistsOrShorter
|
insertIfNotExistsOrShorter
|
||||||
(dist, eKeys, eVals, foldPlatID, q, curPlatID)
|
(dist, eKeys, eVals, foldPlatID, q, curPlatID)
|
||||||
|
|||||||
Reference in New Issue
Block a user