From c80b61ba6c63f0616862c24e3150f2803d634a6c Mon Sep 17 00:00:00 2001 From: Jeremy Saklad Date: Tue, 15 Jun 2021 06:56:05 -0500 Subject: [PATCH] Add Bazaarine option of Colourful Phantasist This buyer scales with the product of implausibility and amalgamy. --- Bone Market Solver.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Bone Market Solver.py b/Bone Market Solver.py index 3c424e9..59936df 100644 --- a/Bone Market Solver.py +++ b/Bone Market Solver.py @@ -1111,6 +1111,11 @@ class Buyer(enum.Enum): cost = Cost.ACTION.value ) + A_COLOURFUL_PHANTASIST_BAZAARINE = Action( + "Sell an amalgamous skeleton as a work of Bazaarine art", + cost = Cost.ACTION.value + ) + THE_DUMBWAITER_OF_BALMORAL = Action( "Export the Skeleton of a Neathy Bird", cost = Cost.ACTION.value @@ -1877,6 +1882,30 @@ def Solve(bone_market_fluctuations, zoological_mania, desired_buyer = None, maxi del value_remainder + # A Colourful Phantasist - Bazaarine + model.Add(skeleton_in_progress >= 100).OnlyEnforceIf(actions[Buyer.A_COLOURFUL_PHANTASIST_BAZAARINE]) + model.Add(implausibility >= 2).OnlyEnforceIf(actions[Buyer.A_COLOURFUL_PHANTASIST_BAZAARINE]) + model.Add(amalgamy >= 4).OnlyEnforceIf(actions[Buyer.A_COLOURFUL_PHANTASIST_BAZAARINE]) + + amalgamy_times_implausibility = model.NewIntVar(cp_model.INT32_MIN, cp_model.INT32_MAX, '{}: {}'.format(Buyer.A_COLOURFUL_PHANTASIST_BAZAARINE.name, 'amalgamy times implausibility')) + model.AddMultiplicationEquality(amalgamy_times_implausibility, [amalgamy, implausibility]) + + value_remainder = model.NewIntVar(0, 49, '{}: {}'.format(Buyer.A_COLOURFUL_PHANTASIST_BAZAARINE.name, 'value remainder')) + model.AddModuloEquality(value_remainder, value, 50) + + model.Add(primary_revenue == value - value_remainder + 100).OnlyEnforceIf(actions[Buyer.A_COLOURFUL_PHANTASIST_BAZAARINE]) + model.Add(secondary_revenue == 250*amalgamy_times_implausibility + 250).OnlyEnforceIf(actions[Buyer.A_COLOURFUL_PHANTASIST_BAZAARINE]) + + model.Add(difficulty_level == 0).OnlyEnforceIf(actions[Buyer.A_COLOURFUL_PHANTASIST_BAZAARINE]) + + # The indirection is necessary for applying an enforcement literal + derived_exhaustion = model.NewIntVar(0, cp_model.INT32_MAX, '{}: {}'.format(Buyer.A_COLOURFUL_PHANTASIST_BAZAARINE.name, 'derived exhaustion')) + model.AddDivisionEquality(derived_exhaustion, amalgamy_times_implausibility, 20) + model.Add(added_exhaustion == derived_exhaustion).OnlyEnforceIf(actions[Buyer.A_COLOURFUL_PHANTASIST_BAZAARINE]) + + del amalgamy_times_implausibility, 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])