mesa-examples icon indicating copy to clipboard operation
mesa-examples copied to clipboard

conways way of life is broken?

Open disgruntled-penguin opened this issue 11 months ago • 4 comments

attempted to run conways game of life

Image

disgruntled-penguin avatar Dec 13 '25 18:12 disgruntled-penguin

Image i could get it to run by wrapping it in singlegrid and then for the idx errors, i added a ghost

self.grid = SingleGrid(width, height, torus=True) 
ghost = Agent(self)
self.grid.place_agent(ghost, (0, 0))

so i think the simulation is running correctly, as in, when population density is at 1, it dissapears instantly but, i cant see any cells except the ghost itself, am i missing something here?, also changed this to "cell_layer" it was "cells" previously, (cell_layer is defined in app.py) i wasnt too sure of this, but replacing it with cells gives error anyways self.cell_layer = PropertyLayer("cell_layer", width, height, False, dtype=bool)

disgruntled-penguin avatar Dec 13 '25 18:12 disgruntled-penguin

Image i added placeholders/dummies to trigger the rendering, becasue the simulation was running, just not showing, let me know if i can PR this:

for _, (x, y) in self.grid.coord_iter():
            dummy = Agent(self) 
            self.grid.place_agent(dummy, (x, y))

disgruntled-penguin avatar Dec 13 '25 19:12 disgruntled-penguin

Still broken on Mesa 3.5.0. Getting this error when running app.py:

ValueError: Unknown space type: <class 'NoneType'> Comes from make_space_component in app.py. it's expecting an actual grid/space but the model only has a PropertyLayer, so it gets None. The dummy agent workaround mentioned above doesn't fix this either.

Happy to look into a proper fix if no one else is working on it. @jackiekazil @disgruntled-penguin @tpike3 @EwoutH

BittuAgarwal1237 avatar Mar 01 '26 06:03 BittuAgarwal1237

I've investigated this issue and have a working fix. The root cause is that Mesa 3.3.1's _scatter() crashes with an IndexError when there are no agents (empty 1D array). My fix attaches the PropertyLayer to an OrthogonalMooreGrid and uses a custom Solara matplotlib component with imshow to render the cells. Opening a PR shortly.

Harshini2411 avatar Mar 02 '26 16:03 Harshini2411