Agents.jl: Equivalent of nearby_agents for grid cells?

Mandatory I’m brand new to Julia and Agents.jl so apologies if this is obvious.

I am making a predator-prey model, following the wolf-sheep example.

My GridSpace has a property “grass”. In the example predator-prey model, sheep move at random to a nearby cell. I would like my sheep to “look” around and move to the nearest cell where there is grass. To do this I think I need something like nearby_agents (but for nearby grid cells) to retrieve a vector of grid cell IDs within range r (sheep vision range). I would then be able to iterate over the nearby cells to see a) which have grass and b) which is closest.

My question: Is there an equivalent of nearby_agents for nearby cells? And does my approach seem sensible?

welcome :slight_smile:

Hah, I was about to say “I think you need nearby_positions”. But I realized, this function doesn’t exist. Which is obviously a neglect from our end, since the code exists. In fact, when you call nearby_agents, an “function” nearby_positions is called first. Please open an issue in the Agents.jl GitHub repository asking for a nearyb positions function :slight_smile:


In the Agents API there is a function Agents.nearby_positions. And in the code as well:
@Datseris Are these the ones you referring to?

1 Like

lol oh well I was dumb :stuck_out_tongue: Yeap, nearby_positions is the function you need :slight_smile:

1 Like