make path incentivisation less aggressive (prefer reaching goal by going through fewer platforms if possible).

This commit is contained in:
2025-01-25 18:36:30 +00:00
parent 6c3621cb3f
commit 3885cc5cbc

View File

@@ -158,9 +158,7 @@ struct
val {y = cy, ...} = foldPlat val {y = cy, ...} = foldPlat
val dist = abs (py - cy) val dist = abs (py - cy)
(* divide by 2 so that we generally "prefer" straight vertical paths val dist = dist + distSoFar
* 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)
@@ -191,7 +189,7 @@ struct
in in
(* divide by 2 so we prefer straight horizontal paths over (* divide by 2 so we prefer straight horizontal paths over
* diagonal ones by giving horizontal ones a lower cost *) * diagonal ones by giving horizontal ones a lower cost *)
(Int.min (min, d4) + distSoFar) div 2 Int.min (min, d4) + distSoFar
end end
else else
let let
@@ -307,11 +305,14 @@ struct
ValSet.insert ValSet.insert
(eVals, {distance = distSoFar, from = comesFrom}, insPos) (eVals, {distance = distSoFar, from = comesFrom}, insPos)
(* on each loop, increment distSoFar by 15.
* Result: paths that require jumps to fewer platforms are
* incentivised a little bit. *)
val env = val env =
{ platforms = platforms { platforms = platforms
, currentPlat = plat , currentPlat = plat
, eKeys = eKeys , eKeys = eKeys
, distSoFar = distSoFar , distSoFar = distSoFar + 15
} }
val state = (eVals, q) val state = (eVals, q)