Skip to content

Commit

Permalink
Add docstring for shuffle_do
Browse files Browse the repository at this point in the history
  • Loading branch information
EwoutH committed Sep 21, 2024
1 parent 6e25c2a commit 823fd09
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mesa/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ def do(self, method: str | Callable, *args, **kwargs) -> AgentSet:
return self

def shuffle_do(self, method: str | Callable, *args, **kwargs) -> AgentSet:
"""Shuffle the agents in the AgentSet and then invoke a method or function on each agent.
It's a fast, optimized version of calling shuffle() followed by do().
"""
agents = list(self._agents.keys())
self.random.shuffle(agents)

Expand Down

0 comments on commit 823fd09

Please sign in to comment.