Created
January 23, 2025 21:29
-
-
Save shawngraham/982aaa304cd1920bd6679535615282d0 to your computer and use it in GitHub Desktop.
initial set up of prog hist mesa abm for mesa 3.1.3 https://programminghistorian.org/en/lessons/simulating-historical-communication-networks-python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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