From 90b769230b71e210d7fdabce763df32e5d861a68 Mon Sep 17 00:00:00 2001 From: Jeremy Saklad Date: Wed, 11 Aug 2021 18:35:15 -0500 Subject: [PATCH] Add skulls fascination for Diplomat This fascination scales with all three skeleton attributes multiplied together. --- bonemarketsolver/data/buyers.py | 4 ++++ bonemarketsolver/solve.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/bonemarketsolver/data/buyers.py b/bonemarketsolver/data/buyers.py index 775a400..a1060b9 100644 --- a/bonemarketsolver/data/buyers.py +++ b/bonemarketsolver/data/buyers.py @@ -153,6 +153,10 @@ class Buyer(Enum): "Sell the Diplomat a fossil insect", cost = Cost.ACTION.value ) + THE_TRIFLING_DIPLOMAT_SKULLS = Action( + "Sell the Diplomat a skeleton with multiple heads", + cost = Cost.ACTION.value + ) def __str__(self): return str(self.value) diff --git a/bonemarketsolver/solve.py b/bonemarketsolver/solve.py index 553cd29..0180250 100644 --- a/bonemarketsolver/solve.py +++ b/bonemarketsolver/solve.py @@ -1164,6 +1164,38 @@ def Solve(shadowy_level, bone_market_fluctuations = None, zoological_mania = Non del non_negative_amalgamy, non_negative_menace, non_negative_antiquity, compromising_documents, value_remainder, derived_exhaustion + # The Trifling Diplomat - Skulls + model.Add(skeleton_in_progress >= 100).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_SKULLS]) + model.Add(skulls >= 5).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_SKULLS]) + + non_negative_amalgamy = model.NewIntVar(cp_model.INT32_MIN, cp_model.INT32_MAX, '{}: {}'.format(Buyer.THE_TRIFLING_DIPLOMAT_SKULLS.name, 'non-negative amalgamy')) + model.AddMaxEquality(non_negative_amalgamy, [amalgamy, 0]) + + non_negative_menace = model.NewIntVar(cp_model.INT32_MIN, cp_model.INT32_MAX, '{}: {}'.format(Buyer.THE_TRIFLING_DIPLOMAT_SKULLS.name, 'non-negative menace')) + model.AddMaxEquality(non_negative_menace, [menace, 0]) + + non_negative_antiquity = model.NewIntVar(cp_model.INT32_MIN, cp_model.INT32_MAX, '{}: {}'.format(Buyer.THE_TRIFLING_DIPLOMAT_SKULLS.name, 'non-negative antiquity')) + model.AddMaxEquality(non_negative_antiquity, [antiquity, 0]) + + compromising_documents = model.NewIntVar(0, cp_model.INT32_MAX, '{}: {}'.format(Buyer.THE_TRIFLING_DIPLOMAT_SKULLS.name, 'compromising documents')) + model.AddGeneralMultiplicationEquality(compromising_documents, non_negative_amalgamy, non_negative_menace, non_negative_antiquity) + + value_remainder = model.NewIntVar(0, 49, '{}: {}'.format(Buyer.THE_TRIFLING_DIPLOMAT_SKULLS.name, 'value remainder')) + model.AddModuloEquality(value_remainder, value, 50) + + model.Add(primary_revenue == value - value_remainder + 50).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_SKULLS]) + model.Add(secondary_revenue == 50*compromising_documents).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_SKULLS]) + + model.Add(difficulty_level == 0).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_SKULLS]) + + # The indirection is necessary for applying an enforcement literal + derived_exhaustion = model.NewIntVar(cp_model.INT32_MIN, cp_model.INT32_MAX, '{}: {}'.format(Buyer.THE_TRIFLING_DIPLOMAT_SKULLS.name, 'derived exhaustion')) + model.AddDivisionEquality(derived_exhaustion, compromising_documents, 100) + model.Add(added_exhaustion == derived_exhaustion).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_SKULLS]) + + del non_negative_amalgamy, non_negative_menace, non_negative_antiquity, compromising_documents, value_remainder, derived_exhaustion + + # Maximize profit margin net_profit = model.NewIntVar(cp_model.INT32_MIN, cp_model.INT32_MAX, 'net profit') model.Add(net_profit == total_revenue - cost)