For my current output it seems particles movements are sequential in nature though I want it to be simultaneously. It looks like they are stepping rather then floating.
Main thing you would want to look into my move!() function cause there at the moment its agent specific movement i guess.
Thank you for help
using Agents
@multiagent struct CELL(ContinuousAgent{2, Float64})
@subagent struct CELL_1
end
@subagent struct CELL_2
end
end
function move!(agent, model)
move_agent!(agent, model, model.dt)
return
end
movement_propensity = 0.5
function movement_time(agent, model, propensity = 1)
t = 0.1 * randn(abmrng(model)) + 1
return clamp(t, 0, Inf)
end
movement_event = AgentEvent(
action! = move!, propensity = movement_propensity
)
events = ( movement_event,)
space2d = ContinuousSpace((1,1); periodic=true)
using Random: Xoshiro
rng = Xoshiro(42)
model = EventQueueABM(CELL, events, space2d; rng, warn = false)
function Cell_model(;
number_of_particles=400,
sides=SVector(1.0, 1.0),
dt=0.1,
max_radius=10.0,
parallel=true
)
# initial random positions
positions = [sides .* rand(SVector{2,Float64}) for _ in 1:number_of_particles]
properties = (; dt)
# Space and agents
space2d = ContinuousSpace(sides; periodic=true)
# define the model properties
model = EventQueueABM(CELL, events, space2d; properties, rng, warn = false)
# Create active agents
for id in 1:number_of_particles
pos = positions[id]
vel = 10 * randn(SVector{2}) # initial velocities)
type = rand(abmrng(model), (CELL_1, CELL_2))
add_agent!(pos, type, model, vel)
end
return model
end
model = Cell_model()
abmqueue(model)
const colormap = Dict(:CELL_1 => "black", :CELL_2 => "gray")
agent_color(agent) = colormap[kindof(agent)]
plotkw = (agent_color, agent_marker = :circle, agent_size = 5)
fig, ax, abmp = abmplot(model; plotkw...)
fig
path = "something/something/"
abmvideo(
path*"first_init_test.mp4",
model;
dt = 0.1, frames = 100,
title = "event based", plotkw...,
)