randint
This commit is contained in:
parent
27b482fb3f
commit
225b01f256
|
@ -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()
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue