Skip to content

Commit

Permalink
shape: 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 6a09426 commit d2ec5bf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions examples/shape_example/shape_example/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@


class Walker(mesa.Agent):
def __init__(self, unique_id, model, pos, heading=(1, 0)):
def __init__(self, unique_id, model, heading=(1, 0)):
super().__init__(unique_id, model)
self.pos = pos
self.heading = heading
self.headings = {(1, 0), (0, 1), (-1, 0), (0, -1)}

Expand All @@ -31,7 +30,7 @@ def make_walker_agents(self):
# heading = (1, 0)
if self.grid.is_cell_empty(pos):
print(f"Creating agent {unique_id} at ({x}, {y})")
a = Walker(unique_id, self, pos, heading)
a = Walker(unique_id, self, heading)
self.schedule.add(a)
self.grid.place_agent(a, pos)
unique_id += 1
Expand Down

0 comments on commit d2ec5bf

Please sign in to comment.