Complexity Explorer Santa Few Institute

Lecture: Epistemological emergence

Lead instructor:

Your progress is not being saved! Enroll now or log in to track your progress or submit homework.

Agent-Based Models with Python: An Introduction to Mesa

Tom Youngman
16 Oct 2024 3:16pm UTC
2
in Agent-Based Models with Python: An Introduction to Mesa

I'm running the code as shown in session 5 but getting the follow error - any ideas?

---------------------------------------------------------------------------

ValueError Traceback (most recent call last)

in ()
----> 1 model = SugarscapeG1mt()

in __init__(self, width, height)
19
20 agent_id = 0
---> 21 for (x,y) in self.grid.coord_iter():
22 max_sugar = sugar_distribution[x,y]
23 if max_sugar > 0:

ValueError: too many values to unpack (expected 2)

Tom Youngman
16 Oct 2024 3:44pm UTC
in Agent-Based Models with Python: An Introduction to Mesa

I've not figured out the error:
for _,(x,y) in self.grid.coord_iter():

needs the brackets around (x,y) removed to become:
for _,x,y in self.grid.coord_iter():

I have forked the session 5 on GitHub and suggested the change

Eka Putri Difayanti
10 Nov 2024 10:37pm UTC
in Agent-Based Models with Python: An Introduction to Mesa

I have the same problem. Did you find a solution?

Geoff Evamy Hill
16 Oct 2024 11:21am UTC
in Agent-Based Models with Python: An Introduction to Mesa

Hi there,
I am getting this error when I run the code from step 7.
"""
self.grid.place_agent(trader, (x,y))
:83: UserWarning: Agent 4139 is being placed with
place_agent() despite already having the position (30, 30). In most
cases, you'd want to clear the current position with remove_agent()
before placing the agent again.
"""

It seems to happen with the code from the github as well. Any ideas?