user1319472
user1319472

Reputation: 71

Netlogo Agents error

I am implementing an evacuation simulation of a lecture hall.And i have two types of students those who sit on tables and extra students who allocated randomly inside the class.So i created two sliders in order to allocate the students at the desired numbers.The sliders are named extrastudents and standarstudents. When the simulation starts i want all the students (both in tables and extras students) to go to the nearest exit ( i have two exits ) .So i implemented that for only the students that are seating down :

ask standarstudents  [
ifelse pycor > 0
[ set target one-of nexits]
[ set target one-of sexits]
face target
]

Nexits is the north exit. Sexits is the south exit.

The problem is that i get this error and i can move on :

ASK expected input to be an agent or agentset but got the number 3 instead. error while observer running ASK.(The number 3 derives from the slider that user is pick) called by procedure SETUP called by Button 'setup'

org.nlogo.nvm.ArgumentTypeException: ASK expected input to be an agent or agentset but got the number 3 instead.

any ideas?

Upvotes: 1

Views: 207

Answers (1)

Nicolas Payette
Nicolas Payette

Reputation: 14972

Well, if you have sliders named extrastudents and standarstudents, those two variables are numeric values representing how many students of each kind you want, not the students themselves. Like the error message says, the ask primitive works with agentsets that represent "who you are asking".

Have you actually created your students? Putting sliders on the interface won't do anything by itself. I would suggest renaming your sliders to something like num-extrastudents and num-standarstudents and then using code like this to initialize your population:

breed [ extrastudents extrastudent ]
breed [ standarstudents standarstudent ]

to setup
  create-standarstudents num-standarstudents
  create-extrastudents num-extrastudents
end

Then, the code you have posted would work because extrastudents and standarstudents would be breeds of turtles, and thus, agentsets.

Upvotes: 2

Related Questions