-
Notifications
You must be signed in to change notification settings - Fork 917
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
Bug in Demographic Prisoner's Dilemma Activation Schedule #2552
Comments
grid = np.zeros((model.grid.width, model.grid.height))
for agent in model.agents:
x, y = agent.cell.coordinate
grid[x,y] = 1 if agent.move == "D" else 0 3 You can rewrite the for loop by iterating over all cells in the model: grid = np.zeros((model.grid.width, model.grid.height))
for cell in model.grid.all_cells:
x, y = cell.coordinate
agent = cell.agents[0] # this assumes there is exactly 1 agent in each cell.
grid[x,y] = 1 if agent.move == "D" else 0 |
Thank you. I used your option 2 and that fixed it. You probably want to
update the *analysis.ipynb* code at
https://github.com/projectmesa/mesa/blob/main/mesa/examples/advanced/pd_grid/
Best,
Steve
…On Wed, Dec 18, 2024 at 1:14 PM Jan Kwakkel ***@***.***> wrote:
coord_iter is something that exists in "old style" spaces and not in the
experimental cell space. Your draw_grid method is therefore not correct.
There are various ways to resolve this.
1. You can use the plotting functionality in
mesa.visualization.mpl_space_drawing
<https://mesa.readthedocs.io/stable/apis/visualization.html#module-mesa.visualization.components.matplotlib_components>
2. You can rewrite the for loop by iterating over all agents in the
model:
grid = np.zeros((model.grid.width, model.grid.height))for agent in model.agents:
x, y = agent.cell.coordinate
grid[x,y] = 1 if agent.move == "D" else 0
3 You can rewrite the for loop by iterating over all cells in the model:
grid = np.zeros((model.grid.width, model.grid.height))for cell in model.grid.all_cells:
x, y = cell.coordinate
agent = cell.agents[0] # this assumes there is exactly 1 agent in each cell.
grid[x,y] = 1 if agent.move == "D" else 0
—
Reply to this email directly, view it on GitHub
<#2552 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEWW7BC3G6C3Q4FRSEUZOB32GHQSPAVCNFSM6AAAAABT3PNMUGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNJSGI3TSMBWGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Steve Genco
cell: 408 420-7770
email: ***@***.***
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
I copied the code for pd_grid into JupyterLab on my computer. When I walked thru it, the code broke on all three activation examples. The error is this:
AttributeError: 'OrthogonalMooreGrid' object has no property layer called 'coord_iter'
.Here's the full error message:
Expected behavior
I was expecting the code to work, as it's a tutorial.
To Reproduce
I've included below the rest of my
ipynb
file. You can check if anything differs from the version on your github site (at https://github.com/projectmesa/mesa/blob/main/mesa/examples/advanced/pd_grid/), but it looks like the error is occurring inside the mesa code, the newcoord_iter
property doesn't seem to be available in the newOrthogonalMooreGrid
class.Additional context
here is the rest of my
ipynb
file:The text was updated successfully, but these errors were encountered: