I’m trying to modify a particle life simulation, but I’m getting this weird error when using abmvideo or abmplot. Here is the minimum example:
using Makie, Agents, TimerOutputs
# import StaticArraysCore: SVector, MVector
using DataStructures: OrderedDict
abstract type ParticleColor end
struct Red <: ParticleColor end
struct Green <: ParticleColor end
struct Yellow <: ParticleColor end
struct Cyan <: ParticleColor end
struct Orange <: ParticleColor end
@agent struct Particle(ContinuousAgent{2, Float64})
color::ParticleColor
end
color_interact(lhs::ParticleColor, rhs::ParticleColor, m::ABM) =
abmproperties(m)[Symbol(string(color_sym(lhs))*'_'*string(color_sym(rhs)))]
color_sym(p::Particle) = color_sym(p.color)
color_sym(::ParticleColor) = :black
color_sym(::Green) = :green
color_sym(::Red) = :red
color_sym(::Orange) = :orange
color_sym(::Cyan) = :cyan
color_sym(::Yellow) = :yellow
properties=OrderedDict(
:red_red => -1:0.1:1,
:red_green => -1:0.1:1,
:red_orange => -1:0.1:1,
:red_cyan => -1:0.1:1,
:green_red => -1:0.1:1,
:green_green => -1:0.1:1,
:green_orange => -1:0.1:1,
:green_cyan => -1:0.1:1,
:orange_red => -1:0.1:1,
:orange_green => -1:0.1:1,
:orange_orange => -1:0.1:1,
:orange_cyan => -1:0.1:1,
:cyan_red => -1:0.1:1,
:cyan_green => -1:0.1:1,
:cyan_orange => -1:0.1:1,
:cyan_cyan => -1:0.1:1,
:viscosity => 0:.01:1,
)
function initialize_model(to=TimerOutput())
extent::NTuple{2, Float64} = 3 .* (500.0, 500.0);
space2d = ContinuousSpace(extent;
periodic=false,
# spacing=20,
);
model = AgentBasedModel(Particle, space2d;
agent_step! = (args...) -> (@timeit to "agent_step!" agent_step!(args...)),
model_step! = (args...) -> (@timeit to "model_step!" model_step!(args...; to=to)),
properties=push!(Dict{Symbol, Float64}(
lhs_rhs=>rand(range)
for (lhs_rhs, range) in properties),
:time_scale => 1.0)
)
for c in [Red(), Green(), Orange(), Cyan()]
for _ in 1:750
vel = SVector(0., 0.)
add_agent!(model, vel, c)
end
end
model
end
agent_step!(agent, model) = move_agent!(agent, model, 0.5)
function model_step!(model; to=TimerOutput())
end
function make_video()
with_theme(theme_dark()) do
abmvideo("/tmp/foo.mp4", initialize_model(), ac=color_sym, as=8.0;
scatterkwargs=(; :markerspace=>:data))
end
end
make_video()
This code gives me the “type Missing has no field ScreenConfig” error. Here is the stack trace:
ERROR: type Missing has no field ScreenConfig
Stacktrace:
[1] getproperty
@ ./Base.jl:49 [inlined]
[2] getscreen(backend::Missing, scene::Scene, _config::Dict{Symbol, Any}, args::Makie.ImageStorageFormat)
@ Makie ~/.julia/packages/Makie/FUAHr/src/display.jl:421
[3] VideoStream(fig::Figure; format::SubString{…}, framerate::Int64, compression::Int64, profile::Nothing, pixel_format::Nothing, loop::Nothing, loglevel::String, visible::Bool, update::Bool, filter_ticks::Bool, backend::Missing, screen_config::@Kwargs{})
@ Makie ~/.julia/packages/Makie/FUAHr/src/ffmpeg-util.jl:262
[4] VideoStream
@ ~/.julia/packages/Makie/FUAHr/src/ffmpeg-util.jl:250 [inlined]
[5] Record(func::AgentsVisualizations.var"#77#80"{…}, figlike::Figure; kw_args::@Kwargs{…})
@ Makie ~/.julia/packages/Makie/FUAHr/src/recording.jl:165
[6] record(func::Function, figlike::Figure, path::String; kw_args::@Kwargs{framerate::Int64, compression::Int64})
@ Makie ~/.julia/packages/Makie/FUAHr/src/recording.jl:148
[7] abmvideo(file::String, model::StandardABM{…}; spf::Nothing, dt::Int64, framerate::Int64, frames::Int64, title::String, showstep::Bool, figure::@NamedTuple{…}, axis::@NamedTuple{}, recordkwargs::@NamedTuple{…}, kwargs::@Kwargs{…})
@ AgentsVisualizations ~/.julia/packages/Agents/WuWeG/ext/AgentsVisualizations/src/convenience.jl:120
[8] (::var"#114#115")()
@ Main ~/Documents/Programming/particle-sim/julia/test.jl:84
[9] (::Makie.var"#330#331"{@Kwargs{}, var"#114#115", Attributes})()
@ Makie ~/.julia/packages/Makie/FUAHr/src/theming.jl:233
[10] lock(f::Makie.var"#330#331"{@Kwargs{}, var"#114#115", Attributes}, l::ReentrantLock)
@ Base ./lock.jl:232
[11] with_theme(f::var"#114#115", theme::Attributes; kwargs::@Kwargs{})
@ Makie ~/.julia/packages/Makie/FUAHr/src/theming.jl:229
[12] with_theme(f::Function, theme::Attributes)
@ Makie ~/.julia/packages/Makie/FUAHr/src/theming.jl:228
[13] make_video()
@ Main ~/Documents/Programming/particle-sim/julia/test.jl:83
[14] top-level scope
@ ~/Documents/Programming/particle-sim/julia/test.jl:88
Thank you!