I am working on a NetLogo model where I have a list of customers and a set of restaurants. The goal is to make the customers go to the nearest restaurant at certain intervals. However, I'm encountering an error message that says ASK expected input to be an agent or agentset
and it points to the line where I ask the customers to perform an action.
This is the whole I error I got :
ASK expected input to be an agent or agentset but got the list
[(turtle 4) (turtle 3) (turtle 6) (turtle 0) (turtle 3) (turtle 1) (turtle 6) (turtle 10) (turtle 2) (turtle 7) (turtle 14) (turtle 13) (turtle 1) (turtle 5) (turtle 10) (turtle 9) (turtle 18) (turtle 17) (turtle 10) (turtle 13) (turtle 17) (turtle 17) (turtle 9) (turtle 6) (turtle 15) (turtle 5) (turtle 20) (turtle 31) (turtle 22) (turtle 18) (turtle 14) (turtle 31) (turtle 16) (turtle 7) (turtle 35) (turtle 39) (turtle 2) (turtle 25) (turtle 24) (turtle 17)] instead.
error while observer running ASK
called by procedure CUSTOMERS-GO-TO-RESTAURANTS
called by procedure GO
called by Button 'go'
Here is the code :
globals [restaurants customers]
to setup
clear-all
set-default-shape turtles "default"
create-turtle "house"
create-customers 40
reset-ticks
end
to create-turtle [ shapess ]
let new-restaurants []
repeat 4 [
create-turtles 1 [
setxy random-xcor random-ycor
set size 3
set shape shapess
]
set new-restaurants lput one-of turtles new-restaurants
]
set restaurants new-restaurants
user-message (word "new-restaurants: " new-restaurants)
end
to create-customers [number] ; Create new customer agents
let new-customers []
repeat number [
create-turtles 1 [
setxy random-xcor random-ycor
set heading random 360
; ... ; Additional turtle setup code
]
set new-customers lput one-of turtles new-customers
]
set customers new-customers
user-message (word "Customers: " new-customers)
end
to go-to-restaurant [customer restaurant]
ask customer [
face restaurant
fd 1
set label [label] of restaurant
]
end
to customers-go-to-restaurants
if ticks mod 12 = 0 [
ask customers [
let customer self
let closest-restaurant min-one-of restaurants [distance customer]
go-to-restaurant customer closest-restaurant
]
]
end
to go
customers-go-to-restaurants
tick
end
I would greatly appreciate any insights or suggestions on how to resolve this issue.
"I tried running the 'go' command in my NetLogo model to simulate the movement of customers to restaurants. I expected the customers to move towards the nearest restaurant and update their labels accordingly. However, instead of the expected behavior, I encountered an error message stating ASK expected input to be an agent or agentset but got the list [(turtle 4) (turtle 3) (turtle 6) ...].
As a result, the simulation did not run successfully."
Feel free to modify this example based on your specific scenario and the error message you encountered.