Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
flee598 opened this issue Jul 4, 2024 · 2 comments
Labels
bug Something isn't working discrete Discrete space related tests

Comments

@flee598
Copy link

flee598 commented Jul 4, 2024

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

@Datseris Datseris added bug Something isn't working tests labels Jul 4, 2024
@Datseris
Copy link
Member

Datseris commented Jul 4, 2024

Right, yeah this is a bug. It must have crept in somewhere during the transition to v6, as it required a lot of refactoring. The reason this bug exists is because we haven't tested this particular function in the test suite.

If you would like to have a crack at fixing the bug via a Pull Request, it would be appreciated. From the error messages we just have to make sure offsets_within_radius_no_0(::GridSpace{2, true}, ::Tuple{Int64, Int64}) works.

@Tortar Tortar added the discrete Discrete space related label Jul 4, 2024
@flee598
Copy link
Author

flee598 commented Jul 4, 2024

I had a look at the code, but it is a little over my head. I'm new to Julia and Agents, and I am not confident I could fix the bug without creating more issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working discrete Discrete space related tests
Projects
None yet
Development

No branches or pull requests

3 participants