In my model, I'm trying to make one turtle (bat) move to another type of turtle (bugs) by searching within a radius first. I want the bat to be able to scan its radius (vision) and then detect the closest bug within this area, and then move towards it.
I've tried this code below (with vision-radius and vision-angle being sliders):
let prey min-one-of bugs in-cone vision-radius vision-angle
ask bats [move-to prey]
However, min-one-of returns an error saying that it needs an agentset and a number block to work. So then have tried the following code:
let prey min-one-of bugs [in-cone vision-radius vision-angle]
ask bats [move-to prey]
This code returns an error, due to "in-cone" needing to have an input on the left, which is bugs.
I didn't know if it was possible to use min-one-of and in-radius/in-cone together or if there is another way to create this procedure?
min-one-ofreturns an error because it is missing the reporter.in-cone vision-radius vision-anglecreates the agentset the minimum should be reported for.min-one-ofadditionally needs a reporter as it is not specific to the distance. it could report the agent with the minimum of any reporter, e.g.xcor. To have the nearest agent you need to create the reporter for the distance ->[distance myself].You will also have to check that
preywill not be empty.Here is the code that should solve what you were looking for