1
"""
2
The agent class for Mesa framework.
3

4
Core Objects: Agent
5

6
"""
7
# mypy
8 3
from mesa.model import Model
9 3
from random import Random
10

11

12 3
class Agent:
13
    """ Base class for a model agent. """
14

15 3
    def __init__(self, unique_id: int, model: Model) -> None:
16
        """ Create a new agent. """
17 3
        self.unique_id = unique_id
18 3
        self.model = model
19 3
        self.pos = None
20

21 3
    def step(self) -> None:
22
        """ A single step of the agent. """
23 3
        pass
24

25 3
    def advance(self) -> None:
26 0
        pass
27

28 3
    @property
29 3
    def random(self) -> Random:
30 3
        return self.model.random

Read our documentation on viewing source code .

Loading