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.
This commit is contained in:
Jeremy Saklad 2021-09-01 14:04:18 -05:00
parent ebd2c2fc48
commit 0f7eb10da8
Signed by: Jeremy Saklad
GPG Key ID: 9CA2149583EDBF84
2 changed files with 18 additions and 8 deletions

View File

@ -129,13 +129,13 @@ class Skull(Enum):
skulls_needed = -1 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( VAKE_SKULL = Action(
"Duplicate the Vake's skull and use it to decorate your (Skeleton Type)", "Duplicate the Vake's skull and use it to decorate your (Skeleton Type)",
cost = Cost.ACTION.value + 6000*Cost.BONE_FRAGMENT.value, cost = Cost.ACTION.value + 6000*Cost.BONE_FRAGMENT.value,
skulls_needed = -1, skulls_needed = -1,
skulls = 1, skulls = 1,
menace = 3 menace = 1
) )
# Licentiate # Licentiate

View File

@ -84,10 +84,6 @@ def Solve(shadowy_level, bone_market_fluctuations = None, zoological_mania = Non
# Skull # Skull
for skull in 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 # 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') 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()])) model.Add(antiquity == cp_model.LinearExpr.ScalProd(actions.values(), [action.value.antiquity for action in actions.keys()]))
# Menace calculation # Menace calculation
menace = model.NewIntVar(cp_model.INT32_MIN, cp_model.INT32_MAX, 'menace') 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 # Implausibility calculation