From 06df9e6304d2cf253d6b0534a979dac1ec5efe18 Mon Sep 17 00:00:00 2001 From: Jeremy Saklad Date: Tue, 3 Aug 2021 15:34:37 -0500 Subject: [PATCH] Add amalgamy fascination for Diplomat This fascination scales with the amount of amalgamy on the skeleton. --- bonemarketsolver/data/buyers.py | 5 +++++ bonemarketsolver/solve.py | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/bonemarketsolver/data/buyers.py b/bonemarketsolver/data/buyers.py index bef0550..775a400 100644 --- a/bonemarketsolver/data/buyers.py +++ b/bonemarketsolver/data/buyers.py @@ -129,6 +129,11 @@ class Buyer(Enum): cost = Cost.ACTION.value ) + THE_TRIFLING_DIPLOMAT_AMALGAMY = Action( + "Sell the Diplomat an amalgamous skeleton", + cost = Cost.ACTION.value + ) + THE_TRIFLING_DIPLOMAT_ANTIQUITY = Action( "Sell the Diplomat an antique skeleton", cost = Cost.ACTION.value diff --git a/bonemarketsolver/solve.py b/bonemarketsolver/solve.py index b9dfb67..553cd29 100644 --- a/bonemarketsolver/solve.py +++ b/bonemarketsolver/solve.py @@ -1025,6 +1025,29 @@ def Solve(shadowy_level, bone_market_fluctuations = None, zoological_mania = Non model.Add(added_exhaustion == 0).OnlyEnforceIf(actions[Buyer.THE_CARPENTERS_GRANDDAUGHTER]) + # The Trifling Diplomat - Amalgamy + model.Add(skeleton_in_progress >= 100).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_AMALGAMY]) + model.Add(amalgamy >= 5).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_AMALGAMY]) + + amalgamy_squared = model.NewIntVar(0, cp_model.INT32_MAX, '{}: {}'.format(Buyer.THE_TRIFLING_DIPLOMAT_AMALGAMY.name, 'amalgamy squared')) + model.AddMultiplicationEquality(amalgamy_squared, [amalgamy, amalgamy]) + + value_remainder = model.NewIntVar(0, 49, '{}: {}'.format(Buyer.THE_TRIFLING_DIPLOMAT_AMALGAMY.name, 'value remainder')) + model.AddModuloEquality(value_remainder, value, 50) + + model.Add(primary_revenue == value - value_remainder + 50).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_AMALGAMY]) + model.Add(secondary_revenue == 50*amalgamy_squared).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_AMALGAMY]) + + model.Add(difficulty_level == 0).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_AMALGAMY]) + + # 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_AMALGAMY.name, 'derived exhaustion')) + model.AddDivisionEquality(derived_exhaustion, amalgamy_squared, 100) + model.Add(added_exhaustion == derived_exhaustion).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_AMALGAMY]) + + del amalgamy_squared, value_remainder, derived_exhaustion + + # The Trifling Diplomat - Antiquity model.Add(skeleton_in_progress >= 100).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_ANTIQUITY]) model.Add(antiquity >= 5).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_ANTIQUITY])