initial model
This commit is contained in:
parent
ce9ca2a30e
commit
27b482fb3f
|
@ -1,5 +1,5 @@
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime
|
||||||
|
|
||||||
class Bakery:
|
class Bakery:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -15,7 +15,7 @@ class Bakery:
|
||||||
self.energy_per_loaf = 0.3 # kWh per loaf
|
self.energy_per_loaf = 0.3 # kWh per loaf
|
||||||
|
|
||||||
# Community / meta-system metrics
|
# Community / meta-system metrics
|
||||||
self.community_trust = 50 # 0-100 score
|
self.community_trust = 50.0 # 0-100 score
|
||||||
self.distribution_log = []
|
self.distribution_log = []
|
||||||
|
|
||||||
def produce_bread(self, requested_loaves):
|
def produce_bread(self, requested_loaves):
|
||||||
|
@ -46,3 +46,13 @@ class Bakery:
|
||||||
"individuals": total_distributed * 0.2
|
"individuals": total_distributed * 0.2
|
||||||
})
|
})
|
||||||
return total_distributed
|
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
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
import numpy as np
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
from classes import Bakery, Member
|
||||||
|
|
||||||
|
def simulate_days(days=30):
|
||||||
|
bakery = Bakery()
|
||||||
|
|
||||||
|
# Initialize members
|
||||||
|
members = [
|
||||||
|
Member("Alex", "baker"),
|
||||||
|
Member("Sam", "organizer"),
|
||||||
|
Member("Jamie", "distributor"),
|
||||||
|
Member("Casey", "volunteer")
|
||||||
|
]
|
||||||
|
|
||||||
|
# Metrics
|
||||||
|
trust_history = []
|
||||||
|
bread_history = []
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# --- Decentralized production decision ---
|
||||||
|
if bakery.flour_stock < 50: # Trigger production proposal
|
||||||
|
votes = [member.vote("produce_bread") for member in members]
|
||||||
|
yes_votes = sum(1 for vote in votes if vote == "yes")
|
||||||
|
|
||||||
|
if yes_votes / len(members) >= 1: # Consensus
|
||||||
|
requested_loaves = 100
|
||||||
|
produced = bakery.produce_bread(requested_loaves)
|
||||||
|
print(f"Day {day}: Produced {produced} loaves")
|
||||||
|
|
||||||
|
# --- Distribute bread ---
|
||||||
|
daily_distribution = bakery.distribute_bread({
|
||||||
|
"mutual_aid": 50, # 50 groups needing bread
|
||||||
|
"individuals": 100 # 100 individuals
|
||||||
|
})
|
||||||
|
|
||||||
|
# --- Update meta-system trust ---
|
||||||
|
bakery.community_trust += daily_distribution * 0.1
|
||||||
|
bakery.community_trust = min(bakery.community_trust, 100)
|
||||||
|
|
||||||
|
# Log metrics
|
||||||
|
trust_history.append(bakery.community_trust)
|
||||||
|
bread_history.append(bakery.bread_stock)
|
||||||
|
|
||||||
|
return trust_history, bread_history
|
Loading…
Reference in New Issue