Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error messages in NetLogo when trying to use `with`

Tags:

netlogo

I'm a new user of NetLogo (5.0.5) and I receive error messages when I try to do pretty basic things. In particular I get

Nothing named x has been defined

when I try to define/use various agentsets. For instance

show turtles with [color=red]

show turtles with [who<10]

ask turtles [set friends turtles with [color=red]]

generate this message (where friends is a turtle variable). However,

ask turtles [set friends turtles in-radius 7]

is ok. So it might have to do with 'with'. I'm not sure what do do here. I was following along Jose Vidal's excellent tutorial

https://www.youtube.com/watch?v=k5RMdrbJXpM&list=PLSx7bGPy9gbFCWOQ6bAb_4ASLIrblXhqP

and everything was working until i tried

show cats with [color=red]

which generated the above error-message. Can anyone help with this?

I haven't found anything about this anywhere but since I'm new there might be resources that do not show up on google (or here) that I've missed.

like image 505
ProfessorHelloKittyNr1 Avatar asked Jan 28 '26 08:01

ProfessorHelloKittyNr1


1 Answers

Unlike some other programming languages, NetLogo doesn't allow you to smash arithmetic and comparison operators up against identifiers; they have to be separated. So you need to write color = red, with the spaces, instead of color=red, and who < 10 instead of who<10. (If you smash them together, NetLogo thinks the whole thing is a single name for something.)

You can smash brackets [] and parentheses () up against other things without spaces, but not other punctuation.

like image 72
Seth Tisue Avatar answered Jan 31 '26 22:01

Seth Tisue