JuliaDynamics / Agents.jl

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

`@multiagent` doesn't work when agents have no extra properties #1002

Closed Datseris closed 4 months ago

Datseris commented 4 months ago

Describe the bug

@multiagent struct RPS(GridAgent{2})
    @subagent Rock end
    @subagent Paper end
    @subagent Scissors end
end

doesn't work, gives:

ERROR: LoadError: MethodError: no method matching iterate(::Nothing)

Closest candidates are:
  iterate(::Base.MethodSpecializations)
   @ Base reflection.jl:1148
  iterate(::Base.MethodSpecializations, ::Nothing)
   @ Base reflection.jl:1154
  iterate(::Base.MethodSpecializations, ::Int64)
   @ Base reflection.jl:1155
  ...

Stacktrace:
  [1] _multiagent(version::QuoteNode, struct_repr::Expr)
    @ Agents C:\Users\datse\.julia\dev\Agents\src\core\agents.jl:324       
  [2] var"@multiagent"(__source__::LineNumberNode, __module__::Module, struct_repr::Any)
    @ Agents C:\Users\datse\.julia\dev\Agents\src\core\agents.jl:313       
  [3] eval
    @ .\boot.jl:385 [inlined]
  [4] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
Datseris commented 4 months ago

Sorry, my bad, forgot the struct after the @subagent...