Beginners Interactive NetLogo Dictionary
Farsi / Persian
NetLogo Models Library:
Note: If you download the NetLogo application, every model in the Models Library is included.
This shows how to capture a movie of your model with the
The model is of a population of birds. Once a bird is 10 ticks old, it can hatch two offspring and die. The number of birds, of course, increases exponentially.
The model provides buttons to start the movie recorder and then save your recording or reset the movie recorder if you don't like what you have recorded so far. The code for these buttons can easily be copied to any user model.
The model can be used like most NetLogo models: click SETUP to initialize the model and then GO to run it.
If you want to make a movie of the model, click START RECORDER at any time. You will notice that the VID:RECORDER-STATUS monitor changes from "inactive" to "recording". Once recording is active, the recorder will capture a frame of the model each time SETUP or GO is executed.
Once you have a movie that you think you will like, you can use the SAVE RECORDING button to save it. NetLogo will prompt you for a file name and automatically add the
.mp4 extension to it if you don't add it yourself.
If you don't want to save your movie and prefer to start over, click RESET RECORDING. The recorder will "forget" everything that it has recorded so far.
If you want to add recording capabilities to your own model, copy the code for
save-recording to the code tab of your model and create the corresponding buttons in your interface tab. You can also add a
vid:recorder-status monitor if you like.
Like any model with exponential population growth, this model slows down after each iteration. As it takes longer for NetLogo to compute each iteration, actual time gets slower and slower relative to "model time" (the number of iterations). Thus, the gray spinner in the upper right corner of the view visibly slows down.
Creating a movie of the model solves the problem. The movie allows us to observe the model while real time and model time progress at a consistent rate. When we replay the movie, the spinner spins at a constant rate.
Note that the model only shows what's happening in the view; it doesn't show monitors updating, and if the model had any plots in it, they wouldn't be shown either. That's because the code uses the
vid:record-view command, which only includes the view in the model. You can substitute
vid:record-interface; then the whole interface tab is grabbed.
A different way of making a movie is to use BehaviorSpace. BehaviorSpace is a tool built into NetLogo that lets you set up automated model runs. Usually BehaviorSpace is used to do many model runs in which you experiment with different settings in a model, but it's also possible to use it to set up a single run in order to make a movie.
This model includes a sample BehaviorSpace "experiment setup" which makes a movie. To try it, choose BehaviorSpace on the Tools menu. In the dialog that opens you'll see an experiment called "make movies". Select that experiment and hit the "Run" button. The model will run three times and a movie files will be generated each time. The
behaviorspace-run-number primitive is used to give each movie a different name.
If you want to see how the experiment was set up, select the experiment in the BehaviorSpace dialog and press the "Edit" button. You'll notice that:
vid:save-recording (word behaviorspace-run-number)
go procedures in the model already include
if vid:recorder-status = "recording" [ vid:record-view ]. If you were trying to record a movie for a model that didn't already have them, you could include calls to
vid:record-view in the "Setup commands" and "Go commands" of the BehaviorSpace experiment.
Together, those commands make a complete movie.
Since it isn't a real experiment, the setup does not vary any variables, and it does not use any reporters to measure the run.