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