Skip to content

Error when trying to search different distances across multiple dimensions of GridSpace #1053

@flee598

Description

@flee598

I'm trying to return nearby_positions() of an agent, searching different distances for each of the dimensions in my GridSpace. When I change r = 3 to r = (1, 3) I get an error. I also get an error with nearby_ids().

Minimal Working Example

using Agents

space = GridSpace((20, 20))

@agent struct test_ag(GridAgent{2}) 
end

function test_step!(agent, model)
        move_agent_single!(agent, model)
end

model = StandardABM(
    test_ag, # type of agents
    space; # space they live in
    agent_step! = test_step!
)

for n in 1:5
    add_agent_single!(model)
end

# works fine
nearby_positions(model[1], model, 3)

# does not work
nearby_positions(model[1], model, (1,3))

# does not work, but returns a different error
nearby_ids(model[1], model, (1,3))

nearby_positions() error: ERROR: MethodError: no method matching offsets_within_radius_no_0(::GridSpace{2, true}, ::Tuple{Int64, Int64})

nearby_ids() error: ERROR: MethodError: no method matching bound_range(::UnitRange{Int64}, ::Int64, ::GridSpace{2, true})

Agents.jl version 6.0.16
Julia version 1.10.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdiscreteDiscrete space relatedtests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions