Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Ark = "0.4"
Ark = "0.5"
PrettyTables = "2"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This repository has been initiated and maintained by the developers of Agents.jl

These are the results of the latest comparison:

| Model/Framework | Agents.jl 6.2.10 | Ark.jl 0.4.0 | MASON 22.0 | Netlogo 6.4.0 | Mesa 3.2.0 |
| Model/Framework | Agents.jl 6.2.10 | Ark.jl 0.5.1 | MASON 22.0 | Netlogo 6.4.0 | Mesa 3.2.0 |
|:------------------:|:------------------:|:--------------:|:------------:|:---------------:|:------------:|
| WolfSheep-small (Time-Ratio) | 1.0 | **0.34** | 5.29 | 9.94 | 9.38 |
| WolfSheep-large (Time-Ratio) | 1.0 | **0.14** | 7.8 | 4.81 | 3.28 |
Expand Down
2 changes: 1 addition & 1 deletion WolfSheep/Agents/WolfSheep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function predator_prey_model(rng, n_sheep, n_wolves, dims,
properties = (fully_grown = falses(dims), countdown = zeros(Int, dims),
regrowth_time = regrowth_time)
scheduler = Schedulers.ByType(true, true, Union{Wolf, Sheep})
model = ABM(Union{Wolf, Sheep}, space; agent_step!, model_step!, scheduler,
model = StandardABM(Union{Wolf, Sheep}, space; agent_step!, model_step!, scheduler,
properties, rng, warn = false)
for _ in 1:n_sheep
energy = rand(abmrng(model), 0:(Δenergy_sheep * 2 - 1))
Expand Down
10 changes: 5 additions & 5 deletions WolfSheep/Ark/WolfSheep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ end

function swap_remove!(v::Vector{Entity}, x::Entity)
idx = findfirst(==(x), v)
if idx !== nothing
@inbounds if idx !== nothing
v[idx] = v[end]
pop!(v)
end
return
end

function sheep_step!(world::World, rng, entities, params, grass, sheep_grid)
@unchecked for entity in entities
@inbounds @unchecked for entity in entities
pos, energy_comp = get_components(world, entity, (Position, Energy))
energy = energy_comp.e

Expand Down Expand Up @@ -118,7 +118,7 @@ function sheep_step!(world::World, rng, entities, params, grass, sheep_grid)
end

function wolf_step!(world::World, rng, entities, params, sheep_grid)
@unchecked for entity in entities
@inbounds @unchecked for entity in entities
pos, energy_comp = get_components(world, entity, (Position, Energy))
energy = energy_comp.e

Expand All @@ -129,7 +129,7 @@ function wolf_step!(world::World, rng, entities, params, sheep_grid)
if !isempty(potential_dinner)
dinner_idx = rand(rng, 1:length(potential_dinner))
dinner = potential_dinner[dinner_idx]
potential_dinner[dinner_idx] = potential_dinner[end]
potential_dinner[dinner_idx] = potential_dinner[lastindex(potential_dinner)]
pop!(potential_dinner)
remove_entity!(world, dinner)
energy += params.Δenergy_wolf
Expand Down Expand Up @@ -171,7 +171,7 @@ function wolfsheep_step!(world::World, rng)
end
end

for i in 1:params.dims[1], j in 1:params.dims[2]
@inbounds for i in 1:params.dims[1], j in 1:params.dims[2]
if !grass.fully_grown[i, j]
if grass.countdown[i, j] <= 0
grass.fully_grown[i, j] = true
Expand Down
Loading