diff --git a/docs/src/devdocs.md b/docs/src/devdocs.md index e3c5931154..4b11c088ad 100644 --- a/docs/src/devdocs.md +++ b/docs/src/devdocs.md @@ -60,6 +60,7 @@ In principle, the following should be done: 5. Extend `add_agent_to_space!(agent, model), remove_agent_from_space!(agent, model)`. This already provides access to `add_agent!, kill_agent!` and `move_agent!`. 6. Extend `nearby_ids(pos, model, r)`. 7. Create a new "minimal" agent type to be used with [`@agent`](@ref) (see the source code of [`GraphAgent`](@ref) for an example). +8. If you want to enable plotting with this space out of the box, also extend [`spacesize`](@ref). And that's it! Every function of the main API will now work. In some situations you might want to explicitly extend other functions such as `move_agent!` or `remove_all_from_space!` for performance reasons. diff --git a/ext/AgentsVisualizations/src/spaces/abstract.jl b/ext/AgentsVisualizations/src/spaces/abstract.jl index bf74105594..178e02a296 100644 --- a/ext/AgentsVisualizations/src/spaces/abstract.jl +++ b/ext/AgentsVisualizations/src/spaces/abstract.jl @@ -183,6 +183,6 @@ function Agents.agent2string(agent::A) where {A<:AbstractAgent} return agentstring end -Agents.convert_element_pos(::S, pos) where {S<:Agents.AbstractSpace} = Tuple(pos) +Agents.convert_element_pos(s::S, pos) where {S<:Agents.AbstractSpace} = Tuple(pos[1:length(spacesize(s))]) Agents.ids_to_inspect(model::ABM, pos) = ids_in_position(pos, model)