Skip to content

Commit

Permalink
make daisyworld use GridSpaceSingle
Browse files Browse the repository at this point in the history
  • Loading branch information
Datseris committed Jul 6, 2022
1 parent e408c11 commit 3271958
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
11 changes: 5 additions & 6 deletions docs/src/agents.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ model, daisy_step!, daisyworld_step! = daisyworld(; solar_luminosity = 1.0, sola
model

# Now, to plot daisyworld is as simple as

daisycolor(a::Daisy) = a.breed # color of agents
as = 14 # size of agents
am = '' # marker of agents
Expand Down Expand Up @@ -126,11 +125,11 @@ abmvideo(

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

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

## and another plot, written in a more condensed format
ax_hist = Axis(plot_layout[2,1];
ax_hist = Axis(plot_layout[2,1];
ylabel = "Distribution of mean temperatures\nacross all time steps")
hist!(ax_hist, @lift($(p.mdf).temperature);
bins = 50, color = :red,
Expand Down
8 changes: 3 additions & 5 deletions src/agents/daisyworld_def.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import StatsBase
using Random


mutable struct Daisy <: AbstractAgent
id::Int
pos::Dims{2}
@agent Daisy GridAgent{2} begin
breed::Symbol
age::Int
albedo::Float64 # 0-1 fraction
end

DaisyWorld = ABM{<:GridSpace, Daisy};
DaisyWorld = ABM{<:GridSpaceSingle, Daisy};

function update_surface_temperature!(pos, model::DaisyWorld)
ids = ids_in_position(pos, model)
Expand Down Expand Up @@ -108,7 +106,7 @@ function daisyworld(;
)

rng = MersenneTwister(seed)
space = GridSpace(griddims)
space = GridSpaceSingle(griddims)
properties = (;max_age, surface_albedo, solar_luminosity, solar_change, scenario,)
properties = Dict(pairs(properties))
properties[:tick] = 0
Expand Down

0 comments on commit 3271958

Please sign in to comment.