Closed Datseris closed 1 year ago
By analyzing some agents, looping through the random agents of the model (when agents are more than possible positions) I see that for some agents
julia> isempty(strategy.pos, model)
true
which doesn't make sense. If an agent is in a GridSpaceSingle model its position can never be empty...
I looked into it, this is the problem:
add_agent_to_space
, so the id in the space will be overwritten and at the same time the agent will be added to the modelwill do a PR about that myself if nobody is working about it at the moment :-)
I think the best fix would be throwing an error if a position is not empty in add_agent_to_space
, but this would mean that the code above will fail
but this would mean that the code above will fail
This is something I don't understand. I'm using isempty
and add_agent_single!
exclusively. So I should never encounter the failing condition, right? Yet I do. I'm confused why :D
ah i'm a f**cking moron:
if isempty(pos, model)
add_agent!(strategy.pos, model, strategy.type)
end
I should add the agent in pos
not strategy.pos
. Oh well, such is the life, thanks to my moronity we uncovered a rather serious bug!
Bugs are usually found by breaking some assumptions :D
Below i am attaching an implementation of a spatial rock paper scissors model we used in a tutorial about Agents.jl. The model is a grid space single, yet agents increase in numbers infinitely, even though we are only using the basic Agents.jl API. Something is wrong somewhere and there is a leakage. One of hte API functions probably needs an additional check...