I want to generate an interactive plot for the wolf-sheep model. I want to make it so that agent traits can be controlled on an interactive slider, for example:
the initial number of sheep (n_sheep) vary between 1 and 20
the probability of sheep reproducing (sheep_reproduce) vary between 0.01 and 0.1 by 0.01 intervals
From what I can see in the “Interactive plotting” tutorial, only model properties can be made changeable on a slider.
I tried the following (from the interactive plotting tutorial):
Yep I am. When I include :n_sheep in properties, pressing the “update” button no longer produces the KeyError: key "n_sheep" not found error, but the initial number of sheep doesn’t change either (the button does nothing).
As you can see here the n_sheep property is only used during initialisation of the model. When you use the interactive application provided by InteractiveDynamics.jl, you already provide an existing model to the plotting function, e.g. fig, ax, abmobs = abmplot(sheepwolfgrass; agent_step! = sheepwolf_step!, model_step! = grass_step!, plotkwargs...). This means that whenever you click the reset model button, you just recreate the exact same model that you’ve had when you started the interactive app. (That’s also the reason why the button is called “reset model” and not “new model” or something similar.)
What you want to do is to create a whole new model on the fly and replace it in the interactive plot. That’s not possible right now. Instead you can just as easily create a new model in the REPL and run the abmplot function again. It’s almost instantaneous so there’s no real downside to it except that you don’t do it via a graphical interface.
Having said that, your expectations regarding the functionality make sense to me. I’ll have a look if I can find the time to implement it.