This commit is contained in:
Shrek Requiem 2025-02-03 16:29:45 -05:00
parent 27b482fb3f
commit 225b01f256
2 changed files with 22 additions and 2 deletions

20
python/src/run.py Normal file
View File

@ -0,0 +1,20 @@
import matplotlib.pyplot as plt
from simulation import simulate_days
trust, bread = simulate_days(days=30)
# Plot results
plt.figure(figsize=(12, 4))
plt.subplot(1, 2, 1)
plt.plot(trust, label="Community Trust")
plt.xlabel("Day")
plt.ylabel("Trust Score")
plt.title("Community Trust Over Time")
plt.subplot(1, 2, 2)
plt.plot(bread, label="Bread Stock", color="orange")
plt.xlabel("Day")
plt.ylabel("Loaves")
plt.title("Bread Inventory")
plt.tight_layout()
plt.show()

View File

@ -19,8 +19,8 @@ def simulate_days(days=30):
for day in range(days):
# --- Daily donations ---
bakery.flour_stock += np.random.randint(10, 2) # ~10kg/day
bakery.energy_stock += np.random.randint(30, 5) # ~30kWh/day
bakery.flour_stock += np.random.randint(2, 10) # ~10kg/day
bakery.energy_stock += np.random.randint(5, 30) # ~30kWh/day
# --- Decentralized production decision ---
if bakery.flour_stock < 50: # Trigger production proposal