From 225b01f25655dd30c1a10381735a68ff2c352719 Mon Sep 17 00:00:00 2001 From: Shrek Requiem Date: Mon, 3 Feb 2025 16:29:45 -0500 Subject: [PATCH] randint --- python/src/run.py | 20 ++++++++++++++++++++ python/src/simulation.py | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 python/src/run.py diff --git a/python/src/run.py b/python/src/run.py new file mode 100644 index 0000000..7e0c64d --- /dev/null +++ b/python/src/run.py @@ -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() diff --git a/python/src/simulation.py b/python/src/simulation.py index f9be27c..d31dc96 100644 --- a/python/src/simulation.py +++ b/python/src/simulation.py @@ -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