Movie Example
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This shows how to capture a movie of your model.
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 procedure make-movie
runs the model, captures the view to a movie, and exports the movie to a file.
HOW TO USE IT
Click make-movie
to capture a movie. NetLogo will prompt you for the location of the movie file.
If you want to make a movie of your own model, you can copy and paste the make-movie
procedure into your model.
THINGS TO NOTICE
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 movie-grab-view
command, which only includes the view in the model. You can substitute movie-grab-interface
; then the whole interface tab is grabbed.
THINGS TO TRY
A different way of making a movie, besides a procedure like make-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, just like the make-movie
procedure. 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. Background runs in parallel BehaviorSpace experiment can't make movies, so change the "Simultaneous number of runs" setting to 1, disabling background runs, and hit "OK". 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:
- the setup commands include
movie-start
andmovie-grab-view
- the go commands include
movie-grab-view
- the final commands include
movie-close
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.
Comments and Questions
breed [ birds bird ] breed [ spinners spinner ] turtles-own [ age ] ;; makes a movie of the model; stops when there are 3000 turtles ;; and exports movie to a file to make-movie ;; prompt user for movie location user-message "First, save your new movie file (choose a name ending with .mov)" let path user-new-file if not is-string? path [ stop ] ;; stop if user canceled ;; run the model setup movie-start path movie-grab-view while [ count turtles < 3000 ] [ go movie-grab-view ] ;; export the movie movie-close user-message (word "Exported movie to " path) end to setup clear-all create-birds 1 create-spinner reset-ticks end to go ask birds [ wander grow-old reproduce ] tick update-spinner end to grow-old set age age + 1 end to wander rt random-float 90 fd 1 end to reproduce if (age > 10 and random 10 > 7) [ hatch 2 [ set color color - 4 + random 10 set age 0 ] die ] end ;; make the spinner for the upper right hand corner to create-spinner create-spinners 1 [ set shape "clock" setxy (max-pxcor - 3) (max-pycor - 3) set color gray - 1.5 set size 6 set heading 0 set label 0 ] end to update-spinner ask spinners [ set heading ticks * 30 set label ticks ] end ; Public Domain: ; To the extent possible under law, Uri Wilensky has waived all ; copyright and related or neighboring rights to this model.
There are 10 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Movie Example.png | preview | Preview for 'Movie Example' | over 12 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.