diff --git a/python/src/classes.py b/python/src/classes.py new file mode 100644 index 0000000..d5317a2 --- /dev/null +++ b/python/src/classes.py @@ -0,0 +1,48 @@ +import numpy as np +from datetime import datetime, timedelta + +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-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