From 32719585f016ef6e7b83bd12c88140cc6710e1c0 Mon Sep 17 00:00:00 2001 From: Datseris Date: Thu, 7 Jul 2022 00:06:37 +0200 Subject: [PATCH] make daisyworld use GridSpaceSingle --- docs/src/agents.jl | 11 +++++------ src/agents/daisyworld_def.jl | 8 +++----- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/docs/src/agents.jl b/docs/src/agents.jl index d44edb0b..8e3b5a95 100644 --- a/docs/src/agents.jl +++ b/docs/src/agents.jl @@ -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 @@ -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) @@ -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, diff --git a/src/agents/daisyworld_def.jl b/src/agents/daisyworld_def.jl index f371da1d..1d498da1 100644 --- a/src/agents/daisyworld_def.jl +++ b/src/agents/daisyworld_def.jl @@ -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) @@ -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