Skip to content

Commit

Permalink
bank_reserves: Don't pass pos
Browse files Browse the repository at this point in the history
Don't pass the position parameter, but just use place_agent. Resolves the duplicate position warning.
  • Loading branch information
EwoutH committed Sep 24, 2024
1 parent d2ec5bf commit 61a300b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/bank_reserves/bank_reserves/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def bank_balance(self):

# subclass of RandomWalker, which is subclass to Mesa Agent
class Person(RandomWalker):
def __init__(self, unique_id, pos, model, moore, bank, rich_threshold):
def __init__(self, unique_id, model, moore, bank, rich_threshold):
# init parent class with required parameters
super().__init__(unique_id, pos, model, moore=moore)
super().__init__(unique_id, model, moore=moore)
# the amount each person has in savings
self.savings = 0
# total loan amount person has outstanding
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 @@ -145,7 +145,7 @@ def __init__(
# set x, y coords randomly within the grid
x = self.random.randrange(self.width)
y = self.random.randrange(self.height)
p = Person(i, (x, y), self, True, self.bank, self.rich_threshold)
p = Person(i, self, True, self.bank, self.rich_threshold)
# place the Person object on the grid at coordinates (x, y)
self.grid.place_agent(p, (x, y))
# add the Person object to the model schedule
Expand Down
3 changes: 1 addition & 2 deletions examples/bank_reserves/bank_reserves/random_walk.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class RandomWalker(mesa.Agent):
# use a Moore neighborhood
moore = True

def __init__(self, unique_id, pos, model, moore=True):
def __init__(self, unique_id, model, moore=True):
"""
grid: The MultiGrid object in which the agent lives.
x: The agent's current x coordinate
Expand All @@ -33,7 +33,6 @@ def __init__(self, unique_id, pos, model, moore=True):
Otherwise, only up, down, left, right.
"""
super().__init__(unique_id, model)
self.pos = pos
self.moore = moore

def random_move(self):
Expand Down

0 comments on commit 61a300b

Please sign in to comment.