Skip to content

Commit

Permalink
bank_reserves/charts: Don't make Bank an Agent
Browse files Browse the repository at this point in the history
It doesn't have a step function and there is only one, so it shouldn't be an Agent, just an Python object.
  • Loading branch information
EwoutH committed Aug 19, 2024
1 parent 1fa7a25 commit 0c6366c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
9 changes: 3 additions & 6 deletions examples/bank_reserves/bank_reserves/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@
Northwestern University, Evanston, IL.
"""

import mesa

from .random_walk import RandomWalker


class Bank(mesa.Agent):
def __init__(self, unique_id, model, reserve_percent=50):
# initialize the parent class with required parameters
super().__init__(unique_id, model)
class Bank:
def __init__(self, model, reserve_percent=50):
self.model = model
# for tracking total value of loans outstanding
self.bank_loans = 0
"""percent of deposits the bank must keep in reserves - this is set via
Expand Down
2 changes: 1 addition & 1 deletion examples/bank_reserves/bank_reserves/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __init__(
)

# create a single bank for the model
self.bank = Bank(1, self, self.reserve_percent)
self.bank = Bank(self, self.reserve_percent)

# create people for the model according to number of people set by user
for i in range(self.init_people):
Expand Down
4 changes: 2 additions & 2 deletions examples/bank_reserves/batch_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ def __init__(
agent_reporters={"Wealth": "wealth"},
)

# create a single bank for the model
self.bank = Bank(1, self, self.reserve_percent)
# create a single bank object for the model
self.bank = Bank(self, self.reserve_percent)

# create people for the model according to number of people set by user
for i in range(self.init_people):
Expand Down
9 changes: 3 additions & 6 deletions examples/charts/charts/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@
Northwestern University, Evanston, IL.
"""

import mesa

from .random_walk import RandomWalker


class Bank(mesa.Agent):
def __init__(self, unique_id, model, reserve_percent=50):
# initialize the parent class with required parameters
super().__init__(unique_id, model)
class Bank:
def __init__(self, model, reserve_percent=50):
self.model = model
# for tracking total value of loans outstanding
self.bank_loans = 0
"""percent of deposits the bank must keep in reserves - this is set via
Expand Down
2 changes: 1 addition & 1 deletion examples/charts/charts/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __init__(
)

# create a single bank for the model
self.bank = Bank(1, self, self.reserve_percent)
self.bank = Bank(self, self.reserve_percent)

# create people for the model according to number of people set by user
for i in range(self.init_people):
Expand Down

0 comments on commit 0c6366c

Please sign in to comment.