From 0f7eb10da8446fee7604b67e9b1102c8b6b01d3c Mon Sep 17 00:00:00 2001 From: Jeremy Saklad Date: Wed, 1 Sep 2021 14:04:18 -0500 Subject: [PATCH] Implement menace scaling for Vake skulls Vake skulls now have diminishing returns beyond the first skull. Menace calculation has been reorganized to accomodate the change. Vake skulls are no longer capped, as the new scaling has been fully implemented. --- bonemarketsolver/data/skulls.py | 4 ++-- bonemarketsolver/solve.py | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/bonemarketsolver/data/skulls.py b/bonemarketsolver/data/skulls.py index c72b506..d37285f 100644 --- a/bonemarketsolver/data/skulls.py +++ b/bonemarketsolver/data/skulls.py @@ -129,13 +129,13 @@ class Skull(Enum): skulls_needed = -1 ) - # Value and implausibility scale with repetition and are implemented separately + # Value, implausibility, and partially menace scale with repetition and are implemented separately VAKE_SKULL = Action( "Duplicate the Vake's skull and use it to decorate your (Skeleton Type)", cost = Cost.ACTION.value + 6000*Cost.BONE_FRAGMENT.value, skulls_needed = -1, skulls = 1, - menace = 3 + menace = 1 ) # Licentiate diff --git a/bonemarketsolver/solve.py b/bonemarketsolver/solve.py index 6d6453c..57bca6c 100644 --- a/bonemarketsolver/solve.py +++ b/bonemarketsolver/solve.py @@ -84,11 +84,7 @@ def Solve(shadowy_level, bone_market_fluctuations = None, zoological_mania = Non # Skull for skull in Skull: - # Interim treatment until diminishing returns are analyzed - if skull == Skull.VAKE_SKULL: - actions[skull] = model.NewBoolVar(skull.value.name) - else: - actions[skull] = model.NewIntVar(0, cp_model.INT32_MAX, skull.value.name) + actions[skull] = model.NewIntVar(0, cp_model.INT32_MAX, skull.value.name) # Appendage for appendage in Appendage: @@ -228,9 +224,23 @@ def Solve(shadowy_level, bone_market_fluctuations = None, zoological_mania = Non antiquity = model.NewIntVar(cp_model.INT32_MIN, cp_model.INT32_MAX, 'antiquity') model.Add(antiquity == cp_model.LinearExpr.ScalProd(actions.values(), [action.value.antiquity for action in actions.keys()])) + # Menace calculation menace = model.NewIntVar(cp_model.INT32_MIN, cp_model.INT32_MAX, 'menace') - model.Add(menace == cp_model.LinearExpr.ScalProd(actions.values(), [action.value.menace for action in actions.keys()])) + + constant_base_menace = model.NewIntVar(cp_model.INT32_MIN, cp_model.INT32_MAX, 'constant base menace') + model.Add(constant_base_menace == cp_model.LinearExpr.ScalProd(actions.values(), [action.value.menace for action in actions.keys()])) + + # Calculate menace from Vake skulls + vake_skull_bonus_menace = model.NewIntVarFromDomain(cp_model.Domain.FromValues([0, 2, 3]), 'vake skull bonus menace') + vake_skulls_times_two = model.NewIntVar(0, cp_model.INT32_MAX, 'vake skulls times two') + model.AddMultiplicationEquality(vake_skulls_times_two, [2, actions[Skull.VAKE_SKULL]]) + model.AddMinEquality(vake_skull_bonus_menace, [vake_skulls_times_two, 3]) + del vake_skulls_times_two + + model.Add(menace == constant_base_menace + vake_skull_bonus_menace) + + del constant_base_menace, vake_skull_bonus_menace # Implausibility calculation