2025-09-03 03:34:30 -07:00

29 lines
1.0 KiB
Python

# Generated by berghain CLI: policy template
# You can customize this however you like. The only requirement is that
# a function named `decide` is defined and returns a bool.
def decide(attributes: dict[str, bool],
tallies: dict[str, int],
mins: dict[str, int],
admitted_count: int,
venue_cap: int) -> bool:
"""A safe default 'pacing' policy.
Logic:
1) Admit if the person has ANY still-needed attribute.
2) Else, admit only if admitting them will still leave enough slots to
finish remaining minimums: (remaining_slots - 1) >= total_remaining_shortfall.
3) If all mins are satisfied, admit everyone.
"""
remaining_slots = venue_cap - admitted_count
remaining_need = {a: max(0, mins.get(a, 0) - tallies.get(a, 0)) for a in mins}
total_need = sum(remaining_need.values())
if total_need == 0:
return True
if any(attributes.get(a, False) and remaining_need[a] > 0 for a in mins):
return True
return (remaining_slots - 1) >= total_need