fixed a bug allowing storing of overwork charge

This commit is contained in:
Pagwin 2026-08-02 14:53:40 -04:00
parent 6ebfeddf81
commit 4f115d9289
No known key found for this signature in database
GPG key ID: 81137023740CA260

View file

@ -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: