Skip to content

Commit

Permalink
Add RPS example to docs (#1011)
Browse files Browse the repository at this point in the history
* Add RPS example to docs

* Update event_rock_paper_scissors.jl

* Update event_rock_paper_scissors.jl

* Update event_rock_paper_scissors.jl

* Update event_rock_paper_scissors.jl
  • Loading branch information
Tortar authored Mar 16, 2024
1 parent 7183b0c commit 3996aff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pages = [
"examples/zombies.md",
"examples/predator_prey.md",
"examples/rabbit_fox_hawk.md",
"examples/event_rock_paper_scissors.md",
"examples.md"
],
"api.md",
Expand Down
10 changes: 5 additions & 5 deletions examples/event_rock_paper_scissors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -274,28 +274,28 @@ adf[1:10, :]

# Let's visualize the population sizes versus time:

using Agents.DataFrames
using CairoMakie

tvec = adf[!, :time]
populations = adf[:, Not(:time)]
alabels = ["rocks", "papers", "scissorss"]
alabels = ["rocks", "papers", "scissors"]

fig = Figure()
fig = Figure();
ax = Axis(fig[1,1]; xlabel = "time", ylabel = "population")
for (i, l) in enumerate(alabels)
lines!(ax, tvec, populations[!, i]; label = l)
end
axislegend(ax)
fig


# ## Visualization

# Visualization for [`EventQueueABM`](@ref) is identical to that for [`StandardABM`](@ref)
# that we learned in the [visualization tutorial](@ref vis_tutorial).
# Naturally, for `EventQueueABM` the `dt` argument of [`abmvideo`](@ref)
# corresponds to continuous time and does not have to be an integer.

using CairoMakie

const colormap = Dict(:Rock => "black", :Scissors => "gray", :Paper => "orange")
agent_color(agent) = colormap[kindof(agent)]
plotkw = (agent_color, agent_marker = :rect, agent_size = 5)
Expand Down

0 comments on commit 3996aff

Please sign in to comment.