-
-
Notifications
You must be signed in to change notification settings - Fork 260
Fix color_patches SolaraViz portrayal + update README #346
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
Changes from 3 commits
2035bf8
73bbd9e
2b61d21
f91cdc9
372ac89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,12 +75,6 @@ def __init__(self, width=20, height=20): | |
| self._grid = OrthogonalMooreGrid( | ||
| (width, height), torus=False, random=self.random | ||
| ) | ||
|
|
||
| # self._grid.coord_iter() | ||
| # --> should really not return content + col + row | ||
| # -->but only col & row | ||
| # for (contents, col, row) in self._grid.coord_iter(): | ||
| # replaced content with _ to appease linter | ||
| for cell in self._grid.all_cells: | ||
| agent = ColorCell(self, ColorCell.OPINIONS[self.random.randrange(0, 16)]) | ||
| agent.move_to(cell) | ||
|
|
@@ -98,15 +92,5 @@ def step(self): | |
|
|
||
| @property | ||
| def grid(self): | ||
| """ | ||
| /mesa/visualization/modules/CanvasGridVisualization.py | ||
| is directly accessing Model.grid | ||
| 76 def render(self, model): | ||
| 77 grid_state = defaultdict(list) | ||
| ---> 78 for y in range(model.grid.height): | ||
| 79 for x in range(model.grid.width): | ||
| 80 cell_objects = model.grid.get_cell_list_contents([(x, y)]) | ||
|
|
||
| AttributeError: 'ColorPatches' object has no attribute 'grid' | ||
| """ | ||
| """Provide backward compatibility for accessing the grid.""" | ||
| return self._grid | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we not using the lastest visualization API here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Sahil-Chhoker, thanks for the review! Since this PR was originally just focused on fixing the missing height/width parameters in the interface and cleaning up the outdated comments as requested by @tpike3, I kept the existing dictionary structure to keep the scope of these changes narrow.
While looking into this, I noticed that several other examples in the repository also still need to be updated to the latest AgentPortrayalStyle visualization API.
Would it be acceptable to get these immediate fixes merged in first so this example runs correctly for users? If so, I'll gladly open a new issue to track the API migration across the whole repository, assign it to myself, and submit a separate PR to update all the examples at once. I figure this will keep the commit history clean and tackle the deprecation globally.
Let me know if this works for you!