Skip to content

Instantly share code, notes, and snippets.

@shawngraham
Created January 23, 2025 21:29
Show Gist options
  • Save shawngraham/982aaa304cd1920bd6679535615282d0 to your computer and use it in GitHub Desktop.
Save shawngraham/982aaa304cd1920bd6679535615282d0 to your computer and use it in GitHub Desktop.
import mesa
class LetterAgent(mesa.Agent):
def __init__(self, model):
super().__init__(model)
self.letters_sent = 0
self.letters_received = 0
def step(self):
print(f"Hi, I am agent {self.unique_id}.")
class LetterModel(mesa.Model):
def __init__(self, N: int, seed=None):
super().__init__(seed=seed)
self.num_agents = N
for _ in range(self.num_agents):
LetterAgent(self)
def step(self):
self.agents.shuffle_do("step")
model = LetterModel(10)
model.step()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment