Skip to content
This repository was archived by the owner on Jun 21, 2024. It is now read-only.

Commit 3271958

Browse files
committed
make daisyworld use GridSpaceSingle
1 parent e408c11 commit 3271958

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

docs/src/agents.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ model, daisy_step!, daisyworld_step! = daisyworld(; solar_luminosity = 1.0, sola
3232
model
3333

3434
# Now, to plot daisyworld is as simple as
35-
3635
daisycolor(a::Daisy) = a.breed # color of agents
3736
as = 14 # size of agents
3837
am = '' # marker of agents
@@ -126,11 +125,11 @@ abmvideo(
126125

127126
# It is possible to inspect agents at a given position by hovering the mouse cursor over
128127
# the scatter points in the agent plot. Inspection is automatically enabled for interactive
129-
# applications (i.e. when either agent or model stepping functions are provided). To
130-
# manually enable this functionality, simply add `enable_inspection = true` as an
128+
# applications (i.e. when either agent or model stepping functions are provided). To
129+
# manually enable this functionality, simply add `enable_inspection = true` as an
131130
# additional keyword argument to the `abmplot`/`abmplot!` call.
132-
# A tooltip will appear which by default provides the name of the agent type, its `id`,
133-
# `pos`, and all other fieldnames together with their current values. This is especially
131+
# A tooltip will appear which by default provides the name of the agent type, its `id`,
132+
# `pos`, and all other fieldnames together with their current values. This is especially
134133
# useful for interactive exploration of micro data on the agent level.
135134

136135
# ![RabbitFoxHawk inspection example](https://github.com/JuliaDynamics/JuliaDynamics/tree/master/videos/agents/RabbitFoxHawk_inspection.png)
@@ -189,7 +188,7 @@ scatterlines!(ax_counts, whites; color = :white, label = "white")
189188
Legend(count_layout[1,2], ax_counts; bgcolor = :lightgrey)
190189

191190
## and another plot, written in a more condensed format
192-
ax_hist = Axis(plot_layout[2,1];
191+
ax_hist = Axis(plot_layout[2,1];
193192
ylabel = "Distribution of mean temperatures\nacross all time steps")
194193
hist!(ax_hist, @lift($(p.mdf).temperature);
195194
bins = 50, color = :red,

src/agents/daisyworld_def.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ import StatsBase
44
using Random
55

66

7-
mutable struct Daisy <: AbstractAgent
8-
id::Int
9-
pos::Dims{2}
7+
@agent Daisy GridAgent{2} begin
108
breed::Symbol
119
age::Int
1210
albedo::Float64 # 0-1 fraction
1311
end
1412

15-
DaisyWorld = ABM{<:GridSpace, Daisy};
13+
DaisyWorld = ABM{<:GridSpaceSingle, Daisy};
1614

1715
function update_surface_temperature!(pos, model::DaisyWorld)
1816
ids = ids_in_position(pos, model)
@@ -108,7 +106,7 @@ function daisyworld(;
108106
)
109107

110108
rng = MersenneTwister(seed)
111-
space = GridSpace(griddims)
109+
space = GridSpaceSingle(griddims)
112110
properties = (;max_age, surface_albedo, solar_luminosity, solar_change, scenario,)
113111
properties = Dict(pairs(properties))
114112
properties[:tick] = 0

0 commit comments

Comments
 (0)