Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Wolf Sheep example to include PropertyLayer #2564

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Make the animal dies if it steps into a cliff cell
  • Loading branch information
mgemaakbar committed Jan 19, 2025
commit dce455cc5f5abe67a2419d1e2627cc2198e030b9
6 changes: 6 additions & 0 deletions mesa/examples/advanced/wolf_sheep/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ def step(self):
"""Execute one step of the animal's behavior."""
# Move to random neighboring cell
self.move()
is_cliff = self.grid.model.cliff.data[self.cell.coordinate[0]][
self.cell.coordinate[1]
]
if is_cliff: # if the cell is a cliff, then the animal dies
self.remove()
return

self.energy -= 1

Expand Down