Error: You can't use ___ in an observe context, because ___ is turtle/link onlu

28 views
Skip to first unread message

Ashish Kumar (A.K. Kulshreshth)

unread,
Jul 15, 2024, 6:00:23 AM (7 days ago) Jul 15
to netlogo-users
I am working on my first NetLogo model, and I get the error above. I have attached my code file. I'll be grateful if people can help debug, and explain what I am doing worng.
Population .docx

Steve Railsback

unread,
Jul 15, 2024, 9:47:55 PM (7 days ago) Jul 15
to netlogo-users
Hello--

This error means that your code includes a primitive that only turtles or links can use, in statements that are instead executed by the Observer.

Your code has several mistakes about whether the observer or turtles are doing something. In particular, it looks like the procedures "assign-age-cohort" and "assign-color" should be executed by each turtle (currently they are executed once by the Observer). To do that, the go procedure should say ask turtles [assign-age-cohort assign-color].

And: are you sure that age, age-num, and age-cohort should not be turtle variables instead of globals?

It will probably help you to re-read the User Manual's Programming Guide, especially the sections on Agents, Procedures, and Ask.

Ashish Kumar (A.K. Kulshreshth)

unread,
Jul 15, 2024, 11:42:15 PM (6 days ago) Jul 15
to netlogo-users
Thanks! I'm in the middle of a course and decided to start trying model building. I will read those sections. It helps to know what to look for amd how to progress. 
Reply all
Reply to author
Forward
0 new messages