Grasshopper Python Trouble - error UnboundNameException

I am a third year architecture student who is new to Python. I’m trying to edit an Agent Systems script in Python to add new behaviors and create predator agents to create a sort of flocking script. However, when I try to add new behaviors or define the predators, I get the same error:

Runtime error (UnboundNameException): name ‘agentSystem’ is not defined

line 90, in script

Not sure where to go from here because the error is not specific in how to fix it. I would appreciate any help you can offer. Thanks. (37.5 KB)


Do you maybe have a typo in agentSystem on or before line 90? Python is case-sensitive.

I’m not in front of a computer but it looks like you are trying to use the agentSystem variable but it is not defined or is defined in another part of the script and line 90 cannot access it (a scope problem).


Hey Graham,

Thanks for the response.
I don’t think it is just a problem with naming, as the script works fine when the add code is hidden and there are no typos that I found in that code. I believe the mistake lies somewhere in the AgentSystem Class, but I don’t know enough to decipher the specific problem.