Add the Enterprising Boot Salesman

This buyer scales with the number of legs on the skeleton.
This commit is contained in:
Jeremy Saklad 2021-07-06 14:18:07 -05:00
parent cf45cd81ce
commit 76a7effb6e
Signed by: Jeremy Saklad
GPG Key ID: 9CA2149583EDBF84
1 changed files with 32 additions and 0 deletions

View File

@ -1149,6 +1149,11 @@ class Buyer(Enum):
cost = Cost.ACTION.value cost = Cost.ACTION.value
) )
AN_ENTERPRISING_BOOT_SALESMAN = Action(
"Sell to the Enterprising Boot Salesman",
cost = Cost.ACTION.value
)
THE_DUMBWAITER_OF_BALMORAL = Action( THE_DUMBWAITER_OF_BALMORAL = Action(
"Export the Skeleton of a Neathy Bird", "Export the Skeleton of a Neathy Bird",
cost = Cost.ACTION.value cost = Cost.ACTION.value
@ -1199,6 +1204,8 @@ class OccasionalBuyer(Enum):
AN_INGENUOUS_MALACOLOGIST = [Buyer.AN_INGENUOUS_MALACOLOGIST] AN_INGENUOUS_MALACOLOGIST = [Buyer.AN_INGENUOUS_MALACOLOGIST]
AN_ENTERPRISING_BOOT_SALESMAN = [Buyer.AN_ENTERPRISING_BOOT_SALESMAN]
DiplomatFascination = Enum( DiplomatFascination = Enum(
'DiplomatFascination', 'DiplomatFascination',
@ -2119,6 +2126,31 @@ def Solve(shadowy_level, bone_market_fluctuations, zoological_mania, occasional_
del exponentiated_tentacles, collated_research, value_remainder, derived_exhaustion del exponentiated_tentacles, collated_research, value_remainder, derived_exhaustion
# An Enterprising Boot Salesman
model.Add(menace <= 0).OnlyEnforceIf(actions[Buyer.AN_ENTERPRISING_BOOT_SALESMAN])
model.Add(amalgamy <= 0).OnlyEnforceIf(actions[Buyer.AN_ENTERPRISING_BOOT_SALESMAN])
model.Add(skeleton_in_progress >= 100).OnlyEnforceIf(actions[Buyer.AN_ENTERPRISING_BOOT_SALESMAN])
model.Add(legs >= 4).OnlyEnforceIf(actions[Buyer.AN_ENTERPRISING_BOOT_SALESMAN])
diamonds = model.NewIntVar(0, cp_model.INT32_MAX, '{}: {}'.format(Buyer.AN_ENTERPRISING_BOOT_SALESMAN.name, 'diamonds'))
model.AddApproximateExponentiationEquality(diamonds, legs, 2.2, MAXIMUM_ATTRIBUTE)
value_remainder = model.NewIntVar(0, 49, '{}: {}'.format(Buyer.AN_ENTERPRISING_BOOT_SALESMAN.name, 'value remainder'))
model.AddModuloEquality(value_remainder, value, 50)
model.Add(primary_revenue == value - value_remainder).OnlyEnforceIf(actions[Buyer.AN_ENTERPRISING_BOOT_SALESMAN])
model.Add(secondary_revenue == 50*diamonds).OnlyEnforceIf(actions[Buyer.AN_ENTERPRISING_BOOT_SALESMAN])
model.Add(difficulty_level == 0).OnlyEnforceIf(actions[Buyer.AN_ENTERPRISING_BOOT_SALESMAN])
# The indirection is necessary for applying an enforcement literal
derived_exhaustion = model.NewIntVar(cp_model.INT32_MIN, cp_model.INT32_MAX, '{}: {}'.format(Buyer.AN_ENTERPRISING_BOOT_SALESMAN.name, 'derived exhaustion'))
model.AddDivisionEquality(derived_exhaustion, diamonds, 100)
model.Add(added_exhaustion == derived_exhaustion).OnlyEnforceIf(actions[Buyer.AN_ENTERPRISING_BOOT_SALESMAN])
del diamonds, value_remainder, derived_exhaustion
# The Dumbwaiter of Balmoral # The Dumbwaiter of Balmoral
model.AddLinearExpressionInDomain(skeleton_in_progress, cp_model.Domain.FromFlatIntervals([180, 189])).OnlyEnforceIf(actions[Buyer.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]) model.Add(value >= 250).OnlyEnforceIf(actions[Buyer.THE_DUMBWAITER_OF_BALMORAL])