From 283bf922434c4cbb8ecd6f1f62dcea16a1218c3c Mon Sep 17 00:00:00 2001 From: Jeremy Saklad Date: Tue, 6 Jul 2021 12:33:03 -0500 Subject: [PATCH] Add bird fascination for Diplomat This fascination effectively requires a Bird declaration, and scales with all three skeleton attributes multiplied together. --- Bone Market Solver.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Bone Market Solver.py b/Bone Market Solver.py index ab5a0cb..aaa6c57 100644 --- a/Bone Market Solver.py +++ b/Bone Market Solver.py @@ -1164,6 +1164,11 @@ class Buyer(Enum): cost = Cost.ACTION.value ) + THE_TRIFLING_DIPLOMAT_BIRD = Action( + "Sell the Diplomat a fossil bird", + cost = Cost.ACTION.value + ) + THE_TRIFLING_DIPLOMAT_FISH = Action( "Sell the Diplomat a fossil fish", cost = Cost.ACTION.value @@ -2150,6 +2155,38 @@ def Solve(shadowy_level, bone_market_fluctuations, zoological_mania, occasional_ del antiquity_squared, value_remainder, derived_exhaustion + # The Trifling Diplomat - Bird + model.AddLinearExpressionInDomain(skeleton_in_progress, cp_model.Domain.FromFlatIntervals([180, 189])).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_BIRD]) + + non_negative_amalgamy = model.NewIntVar(cp_model.INT32_MIN, cp_model.INT32_MAX, '{}: {}'.format(Buyer.THE_TRIFLING_DIPLOMAT_BIRD.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_BIRD.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_BIRD.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_BIRD.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_BIRD.name, 'value remainder')) + model.AddModuloEquality(value_remainder, value, 50) + + model.Add(primary_revenue == value - value_remainder + 50).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_BIRD]) + model.Add(secondary_revenue == 50*compromising_documents).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_BIRD]) + + # TODO: Add actual difficulty level + model.Add(difficulty_level == 0).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_BIRD]) + + # 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_BIRD.name, 'derived exhaustion')) + model.AddDivisionEquality(derived_exhaustion, compromising_documents, 100) + model.Add(added_exhaustion == derived_exhaustion).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_BIRD]) + + del non_negative_amalgamy, non_negative_menace, non_negative_antiquity, compromising_documents, value_remainder, derived_exhaustion + + # The Trifling Diplomat - Fish model.AddLinearExpressionInDomain(skeleton_in_progress, cp_model.Domain.FromFlatIntervals([190, 199])).OnlyEnforceIf(actions[Buyer.THE_TRIFLING_DIPLOMAT_FISH])