fix: preserve deterministic decisions across saves
This commit is contained in:
@@ -27,7 +27,7 @@ func update_modifiers() -> void:
|
||||
food_modifier = 2.0
|
||||
if wood <= 0:
|
||||
wood_modifier = 2.0
|
||||
if safety < 20:
|
||||
if _strictly_below(safety, 20.0):
|
||||
safety_modifier = 2.0
|
||||
if knowledge > 25:
|
||||
knowledge_modifier = 0.75
|
||||
@@ -46,24 +46,24 @@ func update_priorities() -> void:
|
||||
safety_priority = 1.0
|
||||
knowledge_priority = 1.0
|
||||
|
||||
if food < 10.0:
|
||||
if _strictly_below(food, 10.0):
|
||||
food_priority = 3.0
|
||||
elif food < 20.0:
|
||||
elif _strictly_below(food, 20.0):
|
||||
food_priority = 2.0
|
||||
|
||||
if wood < 5.0:
|
||||
if _strictly_below(wood, 5.0):
|
||||
wood_priority = 2.5
|
||||
elif wood < 15.0:
|
||||
elif _strictly_below(wood, 15.0):
|
||||
wood_priority = 1.75
|
||||
|
||||
if safety < 25.0:
|
||||
if _strictly_below(safety, 25.0):
|
||||
safety_priority = 3.0
|
||||
elif safety < 50.0:
|
||||
elif _strictly_below(safety, 50.0):
|
||||
safety_priority = 1.5
|
||||
|
||||
if knowledge < 5.0:
|
||||
if _strictly_below(knowledge, 5.0):
|
||||
knowledge_priority = 1.75
|
||||
elif knowledge < 15.0:
|
||||
elif _strictly_below(knowledge, 15.0):
|
||||
knowledge_priority = 1.25
|
||||
|
||||
if debug_logs:
|
||||
@@ -147,3 +147,9 @@ func get_priority_summary() -> String:
|
||||
func debug_log(message: String) -> void:
|
||||
if debug_logs:
|
||||
print("[Village] ", message)
|
||||
|
||||
|
||||
static func _strictly_below(value: float, threshold: float) -> bool:
|
||||
# JSON round trips can normalize a value a few ULPs below a threshold to the
|
||||
# exact decimal. Treat that boundary identically before and after saving.
|
||||
return value < threshold and not is_equal_approx(value, threshold)
|
||||
|
||||
Reference in New Issue
Block a user