Skip to content

Commit

Permalink
Update graph.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar authored Sep 9, 2024
1 parent 191b3a6 commit a269911
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/spaces/graph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ end
#######################################################################################
random_position(model::ABM{<:GraphSpace}) = rand(abmrng(model), 1:nv(model))

function remove_agent_from_space!(agent::AbstractAgent, model::ABM{<:GraphSpace})
agentpos = agent.pos
function remove_agent_from_space!(a::AbstractAgent, model::ABM{<:GraphSpace})
agentpos = a.pos
ids = ids_in_position(agentpos, model)
ai = findfirst(a -> a == agent.id, ids)
isnothing(ai) && error(lazy"Tried to remove $(agent) from the space, but that agent is not on the space")
ai = findfirst(id -> id == a.id, ids)
isnothing(ai) && error(lazy"Tried to remove agent with ID $(a.id) from the space, but that agent is not on the space")
deleteat!(ids, ai)
return agent
end
Expand Down

0 comments on commit a269911

Please sign in to comment.