projectmesa / mesa

Mesa is an open-source Python library for agent-based modeling, ideal for simulating complex systems and exploring emergent behaviors.
https://mesa.readthedocs.io
Apache License 2.0
2.55k stars 898 forks source link

Make experimental cell spaces work with PropertyLayer #2059

Open quaquel opened 9 months ago

quaquel commented 9 months ago

What's the problem this feature will solve? PropertyGrid only works in conjunction with the established classes in space.py, but not yet with the new experiment cell spaces.

Describe the solution you'd like Make PropertyGrid work with cell spaces.

EwoutH commented 9 months ago

For reference, PropertyLayer was implemented in https://github.com/projectmesa/mesa/pull/1898. So the functionality of the PropertyGrid needs to be ported to the experimental cell space, so it works with PropertyLayers.

quaquel commented 1 month ago

Support has been added in #2319

EwoutH commented 1 month ago

Partly yes, but only basic functions are in, and not yet the extensive multi-propertylayer handeling stuff that is in _PropertyGrid.

quaquel commented 1 month ago

I had a look at _PropertyGrid because of #2440. It relies on 3 methods/attributes of _Grid: width, height, and get_neighborhood. The first two are available in new style Grid; the third, however, is defined at the Cell. So addressing this issue for new style grids probably means moving get_neighborhood_mask into Cell, or, probably even better, its own mixin.

Part of the issue is that Cell is used in Network and VoronoiGrid and, at least for now, because of #2431, I would not be in favor of trying to make property layers work in those spaces.

This also reinforces the point made in #2440 of moving property layer stuff into its own namespace seems sensible.]

So my current idea is to have a HasPropertyLayers mixin that can be combined with Grid (and who knows what else in the future), and HasProperties mixing for Cell.