import streamlit as st import asyncio import threading import random import time import psutil import plotly.graph_objects as go # Yoruba gods and their roles gods = { "Olorun": "Supreme Creator", "Obatala": "God of Creation", "Eshu": "Trickster God of Crossroads and Fate", "Orunmila": "God of Wisdom and Divination", "Ikú": "God of Death", "Shango": "God of Thunder and Lightning", "Oshun": "Goddess of Love, Beauty, and Fertility", "Ogun": "God of Iron and War" } # Story of Olorun and Yoruba gods story = """ ... """ # Streamlit app def main(): st.title("Yoruba Gods and Mythology") st.write(story) st.sidebar.title("Simulation") timer_duration = st.sidebar.slider("Timer Duration (seconds)", min_value=1, max_value=60, value=60) if st.sidebar.button("Start Simulation"): simulate(timer_duration) def simulate(duration): start_time = time.time() end_time = start_time + duration agents = [] for i in range(8): agent = threading.Thread(target=agent_function, args=(i,)) agents.append(agent) agent.start() while time.time() < end_time: remaining_time = int(end_time - time.time()) st.write(f"⏰ Time Remaining: {remaining_time} seconds") for i, agent in enumerate(agents): if agent.is_alive(): st.write(f"Agent {i+1}: {agent.message}") else: st.write(f"Agent {i+1}: Idle") update_process_metrics() time.sleep(1) for agent in agents: agent.join() st.success("Simulation completed.") def agent_function(agent_id): thread = threading.current_thread() god_name = list(gods.keys())[agent_id] role = gods[god_name] thread.message = f"{god_name} - {role}" asyncio.run(simulate_task(agent_id)) async def simulate_task(agent_id): await asyncio.sleep(random.uniform(1, 5)) def update_process_metrics(): thread_count = threading.active_count() cpu_percent = psutil.cpu_percent() mem_percent = psutil.virtual_memory().percent fig = go.Figure( data=[ go.Bar(name="Thread Count", x=["Metrics"], y=[thread_count]), go.Bar(name="CPU Usage (%)", x=["Metrics"], y=[cpu_percent]), go.Bar(name="Memory Usage (%)", x=["Metrics"], y=[mem_percent]) ], layout=go.Layout( title="Process Metrics", xaxis=dict(title="Metrics"), yaxis=dict(title="Value"), barmode="group" ) ) st.plotly_chart(fig) if __name__ == "__main__": main()