From a860c8acde34a14246e00c5681bce0c474acbd03 Mon Sep 17 00:00:00 2001 From: Jeremy Saklad Date: Tue, 22 Jun 2021 08:25:12 -0500 Subject: [PATCH] Add the Ingenuous Malacologist This buyer scales with the number of tentacles on the skeleton. --- Bone Market Solver.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Bone Market Solver.py b/Bone Market Solver.py index ae7abe2..37b76c6 100644 --- a/Bone Market Solver.py +++ b/Bone Market Solver.py @@ -1144,6 +1144,11 @@ class Buyer(Enum): cost = Cost.ACTION.value ) + AN_INGENUOUS_MALACOLOGIST = Action( + "Sell him a tentacle-laden skeleton", + cost = Cost.ACTION.value + ) + THE_DUMBWAITER_OF_BALMORAL = Action( "Export the Skeleton of a Neathy Bird", cost = Cost.ACTION.value @@ -1176,6 +1181,8 @@ class OccasionalBuyer(Enum): Buyer.A_COLOURFUL_PHANTASIST_CELESTIAL, ] + AN_INGENUOUS_MALACOLOGIST = [Buyer.AN_INGENUOUS_MALACOLOGIST] + def Solve(shadowy_level, bone_market_fluctuations, zoological_mania, occasional_buyer = None, desired_buyers = [], maximum_cost = cp_model.INT32_MAX, maximum_exhaustion = cp_model.INT32_MAX, time_limit = float('inf'), workers = cpu_count(), stdscr = None): model = cp_model.CpModel() @@ -2019,6 +2026,32 @@ def Solve(shadowy_level, bone_market_fluctuations, zoological_mania, occasional_ del antiquity_times_implausibility, knob_of_scintillack, value_remainder, derived_exhaustion + # An Ingenuous Malacologist + model.Add(tentacles >= 4).OnlyEnforceIf(actions[Buyer.AN_INGENUOUS_MALACOLOGIST]) + model.Add(skeleton_in_progress >= 100).OnlyEnforceIf(actions[Buyer.AN_INGENUOUS_MALACOLOGIST]) + + exponentiated_tentacles = model.NewIntVar(0, cp_model.INT32_MAX, '{}: {}'.format(Buyer.AN_INGENUOUS_MALACOLOGIST.name, 'exponentiated tentacles')) + model.AddApproximateExponentiationEquality(exponentiated_tentacles, tentacles, 2.2, MAXIMUM_ATTRIBUTE) + + collated_research = model.NewIntVar(cp_model.INT32_MIN, cp_model.INT32_MAX, '{}: {}'.format(Buyer.AN_INGENUOUS_MALACOLOGIST.name, 'collated research')) + model.AddDivisionEquality(collated_research, exponentiated_tentacles, 5) + + value_remainder = model.NewIntVar(0, 249, '{}: {}'.format(Buyer.AN_INGENUOUS_MALACOLOGIST.name, 'value remainder')) + model.AddModuloEquality(value_remainder, value, 250) + + model.Add(primary_revenue == value - value_remainder + 250).OnlyEnforceIf(actions[Buyer.AN_INGENUOUS_MALACOLOGIST]) + model.Add(secondary_revenue == 250*collated_research).OnlyEnforceIf(actions[Buyer.AN_INGENUOUS_MALACOLOGIST]) + + model.Add(difficulty_level == 60*implausibility).OnlyEnforceIf(actions[Buyer.AN_INGENUOUS_MALACOLOGIST]) + + # The indirection is necessary for applying an enforcement literal + derived_exhaustion = model.NewIntVar(cp_model.INT32_MIN, cp_model.INT32_MAX, '{}: {}'.format(Buyer.AN_INGENUOUS_MALACOLOGIST.name, 'derived exhaustion')) + model.AddDivisionEquality(derived_exhaustion, exponentiated_tentacles, 100) + model.Add(added_exhaustion == derived_exhaustion).OnlyEnforceIf(actions[Buyer.AN_INGENUOUS_MALACOLOGIST]) + + del exponentiated_tentacles, collated_research, value_remainder, derived_exhaustion + + # The Dumbwaiter of Balmoral model.AddLinearExpressionInDomain(skeleton_in_progress, cp_model.Domain.FromFlatIntervals([180, 189])).OnlyEnforceIf(actions[Buyer.THE_DUMBWAITER_OF_BALMORAL]) model.Add(value >= 250).OnlyEnforceIf(actions[Buyer.THE_DUMBWAITER_OF_BALMORAL])