projectmesa / mesa-examples

Seminal agent-based models developed using Mesa
Other
105 stars 123 forks source link

Bug: sugarscape_g1mt model ValueError #125

Closed dylan-munson closed 2 months ago

dylan-munson commented 2 months ago

Following error is thrown when trying to run the sugarscape_g1mt model out of the box:

File ~/mesa-examples-main/examples/sugarscape_g1mt/sugarscape_g1mt/model.py:97 in __init__ for _,(x,y) in self.grid.coord_iter():

Problem area of code is thus:

agent_id = 0 for _, (x, y) in self.grid.coord_iter(): max_sugar = sugar_distribution[x, y] max_spice = spice_distribution[x, y] resource = Resource(agent_id, self, (x, y), max_sugar, max_spice) self.schedule.add(resource) self.grid.place_agent(resource, (x, y)) agent_id += 1

Note that this region of code differs from the Complexity Explorer example.

dylan-munson commented 2 months ago

Issue seems to be a misplaced parenthesis: the second line in the block of code should read:

for (_, x, y)

rht commented 2 months ago

_, (x, y) is correct. If your versions works for you, it means your Mesa version is outdated.

dylan-munson commented 2 months ago

Yes, I did realize my Mesa version was outdated and updating fixed the issue in the original code. Thank you!