Agents.jl: subset object returned from nearby_positions

I think what you want to do is to iterate over near_cells and check whether those positions are set to true inside model.fully_grown. Correct?

A simple way to do it without modifying the near_cells variable (which is possibly used somewhere else) could be:

grassy_cells = []
for cell in near_cells
    if model.fully_grown[cell...]
        push!(grassy_cells, cell)
    end
end

(Didn’t test this snippet but it might explain to you what you need to know to solve your problem.)

2 Likes