From 4f115d92894e25569537741e2e7fb807b0c973d0 Mon Sep 17 00:00:00 2001 From: Pagwin Date: Sun, 2 Aug 2026 14:53:40 -0400 Subject: [PATCH] fixed a bug allowing storing of overwork charge --- solve.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/solve.py b/solve.py index 4827466..bf0d69c 100644 --- a/solve.py +++ b/solve.py @@ -676,9 +676,11 @@ class _Builder: falls on. The flow equation ``pending' = pending + arm - overwork`` over 0/1 - variables is what ties this together; because ``pending`` is a Bool it - also rules out arming a City that is already holding a charge (unless - that Turn's Collection spends it), which would be wasted anyway. + variables is what ties this together. Charges never stack: the Planner + is not placed on a City that is already holding one (``arm + pending + <= 1``), even on a Turn whose Collection would spend that charge - the + Collection is doubled once either way, so the placement would buy + nothing while quietly banking a second charge. """ m = self.m overwork_agents = [ai for ai, a in enumerate(agents) if a.overwork] @@ -711,8 +713,11 @@ class _Builder: m.Add(ow <= pend + arm) # A carried charge is not optional: Collecting spends it. m.Add(ow >= pend + collect - 1) - # Charge flow. ``ow_pending`` being a Bool caps this at one - # charge per City at a time. + # No stacking: don't arm a City that already holds a charge. + # Without this the Planner could arm a City on the very Turn + # its held charge fires, spending one and banking another. + m.Add(arm + pend <= 1) + # Charge flow. m.Add(self.ow_pending[(ci, t + 1)] == pend + arm - ow) # An Overworked Collection locks the next Turn's Collect. if t + 1 < self.T: