-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmulti_round.py
More file actions
57 lines (47 loc) · 1.52 KB
/
multi_round.py
File metadata and controls
57 lines (47 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from environments.conclave_env import ConclaveEnv
from agents.base import Agent
import pandas as pd
import logging
import datetime
import os
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
# Ensure the logs directory exists
os.makedirs('logs', exist_ok=True)
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler(f"logs/multi_round_run_{timestamp}.log"),
# logging.StreamHandler()
]
)
# Create a logger for your module
logger = logging.getLogger(__name__)
def main():
# Create the environment
env = ConclaveEnv()
# Read cardinals from CSV file
cardinals_df = pd.read_csv('cardinal_electors_2025.csv')
# Create Agent instances and add them to env.agents
# counter = 0
for idx, row in cardinals_df.iterrows():
# counter += 1
# if counter > 10:
# break
agent = Agent(
agent_id=idx,
name=row['Name'],
background=row['Background'],
env=env
)
env.agents.append(agent)
# Set the number of agents in the environment
env.num_agents = len(env.agents)
logger.info(f"\n{env.list_candidates_for_prompt(randomize=False)}")
winner_found = False
while not winner_found:
winner_found = env.run_voting_round()
print(f"winner_found: {winner_found}")
print(f"Winner found: Cardinal {env.winner} - {env.agents[env.winner].name}")
if __name__ == "__main__":
main()