JuliaDynamics / Agents.jl

Agent-based modeling framework in Julia
https://juliadynamics.github.io/Agents.jl/stable/
MIT License
736 stars 119 forks source link

BoundsError when inspecting agents in 3D visualisation #1040

Open jdm204 opened 4 months ago

jdm204 commented 4 months ago

Describe the bug Indexing error when inspecting agents (enable_inspection = true) in abmplot etc for 3D models.

BoundsError: attempt to access 10×10×10 Array{Int64, 3} at index [0, 0, 0]

Minimal Working Example

@agent struct A3D(GridAgent{3}) end

function simple3d_step!(model)
    has_empty_positions(model) || return
    agent = random_agent(model, notsurrounded(model))   
    newpos = rand(abmrng(model), collect(empty_nearby_positions(agent, model)))
    add_agent!(newpos, model)
end

function init_simple3d(;
    dims = (10, 10, 10),
    model_step! = simple3d_step!)
    space = GridSpaceSingle(dims)   
    model = StandardABM(
        A3D,
        space;
        model_step!)
    add_agent!(dims .÷ 2, model)
    model
end

function simple3d_exploration()
    model = init_simple3d()
    abmplot(model;
        enable_inspection=true)
end
f, _ = simple3d_exploration(); f
# mouseover the agent

Agents.jl version

Agents.jl 6.0.12