Add support for drawing discrete grids#2386
Conversation
|
Performance benchmarks:
|
|
Uninstall your current mesa, |
Thanks! This gave me the idea for a slightly different approach: insert the correct version of mesa into sys.path at the top. Based on this, I can confirm that this code works as intended. Let me know what else would be needed to complete this PR since its my first contribution to the visualization side of things. |
That's the other obvious way to go, both have their advantages based on what your working on. @Corvince I'm also quite new to this stack, could you please review this one? |
Corvince
left a comment
There was a problem hiding this comment.
I think this PR is very fine and a good first step. I pre-approve this, just please also add OrthogonalVonNeumann
|
|
||
| import mesa | ||
| from mesa.experimental.cell_space import VoronoiGrid | ||
| from mesa.experimental.cell_space import OrthogonalMooreGrid, VoronoiGrid |
There was a problem hiding this comment.
This should also work for OrthogonalVonNeumannGrid
There was a problem hiding this comment.
yes, I'll fix that! Just need to figure out how to capture this in the match case statement.
I guess it even will work for hexgrids (although we might want to visualize these a bit differently with offsets for every odd row.
| space = getattr(model, "space", None) | ||
|
|
||
| if isinstance(space, mesa.space._Grid): | ||
| _draw_grid(space, space_ax, agent_portrayal, propertylayer_portrayal, model) |
There was a problem hiding this comment.
Hi @quaquel, I understand that this is already merged. May I ask whether it is intentional to remove the call to _draw_grid() here? Thanks!
There was a problem hiding this comment.
I guess I made a mistake. I'll put in a PR to fix this asap.
Thanks for the post-merge review!
|
One improvement for this function would be to use the |
I looked at that and I could not use it because that method is hard coded to only work with |
Add support for drawing experimental Grid Spaces (i.e. HexGrid, OrthogonalMooreGrid, OrthogonalVonNeumannGrid).
Closes #2377. This code needs further refinement (e.g., duplication of agent potrayal code from voroinoi grid, offsets for hexgrids, and adding experiment NetworkGrids).