Hi,
Just curious to find out if it is possible to use keyword argument with add_agent!() function.
When I tried adding a keyword argument, I got the following error : LoadError: MethodError: No Method matching CasAgent(::Int64, ::Typle{Int64, Int64}; TS = 2)
using Agents
mutable struct CasAgent <: AbstractAgent
id::Int
pos::Dims{2}
TS::Int
end
space = GridSpace((10,10), periodic = false)
model = AgentBasedModel(
CasAgent,
space,
scheduler = random_activation
)
for pos in position(model)
add_agent!(
pos,
model,
TS = 2
)
end
#Out > LoadError: MethodError: No Method matching CasAgent(::Int64, ::Typle{Int64, Int64}; TS = 2)
Of course removing the keyword would work fine. But I am wondering if there is a way to include a keyword.
for pos in position(model)
add_agent!(
pos,
model,
2
)
end
#Out > AgentBasedModel with 100 agents of type CasAgent4
I also tried using the @kwdef
from the base package but it didn’t work either
using Base::@kwdef
@kwdef mutable struct CasAgent <: AbstractAgent
id::Int
pos::Dims{2}
TS::Int
end
for pos in position(model)
add_agent!(
pos,
model,
TS = 2
)
end
#Out > LoadError: MethodError: No Method matching CasAgent(::Int64, ::Typle{Int64, Int64}; TS = 2)