-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLanguage Evolution Simulation.py
More file actions
33 lines (25 loc) · 975 Bytes
/
Language Evolution Simulation.py
File metadata and controls
33 lines (25 loc) · 975 Bytes
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
import random
# Define parameters
num_agents = 20
num_iterations = 100
num_symbols = 10
# Create agents with random initial languages
agents = [{'language': [random.choice(range(num_symbols))]} for _ in range(num_agents)]
# Simulate language evolution
for iteration in range(num_iterations):
# Communication between agents
sender_idx = random.randint(0, num_agents - 1)
receiver_idx = random.randint(0, num_agents - 1)
sender = agents[sender_idx]
receiver = agents[receiver_idx]
# Randomly select a symbol to communicate
symbol_to_send = random.choice(sender['language'])
# Receiver learns or misunderstands the symbol
if random.random() < 0.1:
symbol_received = random.choice(range(num_symbols))
else:
symbol_received = symbol_to_send
receiver['language'].append(symbol_received)
# Print the final languages of the agents
for idx, agent in enumerate(agents):
print(f"Agent {idx}: {agent['language']}")