import numpy as np from datetime import datetime class Bakery: def __init__(self): # Resources stock self.flour_stock = 100 # kg self.yeast_stock = 10 # kg self.energy_stock = 200 # kWh self.bread_stock = 0 # loaves # Production variables self.flour_per_loaf = 0.5 # kg per loaf self.yeast_per_loaf = 0.02 # kg per loaf self.energy_per_loaf = 0.3 # kWh per loaf # Community / meta-system metrics self.community_trust = 50.0 # 0-100 score self.distribution_log = [] def produce_bread(self, requested_loaves): # Max possible loaves max_flour = self.flour_stock // self.flour_per_loaf max_yeast = self.yeast_stock // self.yeast_per_loaf max_energy = self.energy_stock // self.energy_per_loaf possible_loaves = min(max_flour, max_yeast, max_energy, requested_loaves) if possible_loaves > 0: # Deduct resources self.flour_stock -= possible_loaves * self.flour_per_loaf self.yeast_stock -= possible_loaves * self.yeast_per_loaf self.energy_stock -= possible_loaves * self.energy_per_loaf # Add bread (with 1% waste) self.bread_stock += int(possible_loaves * 0.99) return possible_loaves def distribute_bread(self, priority_groups): # Allocate 80% to mutual aid network, 20% to individuals (commune can and should feed themselves if possible) total_distributed = min(self.bread_stock, priority_groups["mutual_aid"] * 0.8 + priority_groups["individuals"] * 0.2) self.bread_stock -= total_distributed self.distribution_log.append({ "date": datetime.now(), "mutual_aid": total_distributed * 0.8, "individuals": total_distributed * 0.2 }) return total_distributed class Member: def __init__(self, name, skill): self.name = name self.skill = skill self.participation_score = np.random.randint(20, 80) self.trust_score = np.random.randint(30, 70) def vote(self, proposal): return "yes" if np.random.rand() > 0.01 else "no" # 1/100 chance for a no