Loading ...
Sorry, an error occurred while loading the content.
 

NetLogo Movie Help!!! (Newbie =( )

Expand Messages
  • Sarah
    Hey guys, I m trying to make a movie out of the netlogo model that was already built. I looked in the FAQ and it gives me a block of code.... although I don t
    Message 1 of 2 , Sep 1 8:13 AM
      Hey guys,

      I'm trying to make a movie out of the netlogo model that was already
      built. I looked in the FAQ and it gives me a block of code....
      although I don't know how to go about inserting that code into the
      current code....Or if that's even the right procedure? Any help would
      be great, thanks a lot in advance!

      -Sarah
    • James Steiner
      Sarah wrote: Hey guys, I m trying to make a movie out of the netlogo model that was already built. I looked in the FAQ and it gives me a block of code....
      Message 2 of 2 , Sep 1 1:30 PM
        Sarah wrote:

        Hey guys,

        I'm trying to make a movie out of the netlogo model that was already
        built. I looked in the FAQ and it gives me a block of code....
        although I don't know how to go about inserting that code into the
        current code....Or if that's even the right procedure? Any help would
        be great, thanks a lot in advance!

        Hi Sarah!

        Here is the example from the FAQ:

        ;; export a 30 frame movie of the view
        setup
        movie-start "out.mov"
        movie-grab-view ;; show the initial state
        repeat 30
        [ go
        movie-grab-view ]
        movie-close

        This example assumes a few things:
        1. That you have a procedure called "setup" that initializes the model.
        2. That you have a procedure called "go" that is run repeatedly to
        make the model go
        3. That you wish to capture the result each time the go procedure runs.
        4. That you do not intend to change settings while the model is
        running (such as by changing sliders or switches)
        5. That you know exactly how many frames (time steps, model steps) you
        want to capture for the movie .
        6. That there is no interrupted movie currently "open".

        To use this example, you would put it inside its own procedure, with a
        "to make-movie" at the beginning and "end" at the end. At the end of
        the post is an extended example, with a bunch of comments that I hope
        will help.

        To use this model, all you need do is paste the code into the
        procedures pane, and then type "record-movie" into the command center.

        Optionally, you could add buttons so that you can run setup and go
        (forever) youself, without making a movie. You can also add a button
        for record-movie (once).
        To extend the abilities, you might add a slider or prompt to select
        the number of frames (beware, this 31 frame movie makes a 10 MB .mov
        fille. That's pretty large.).

        This is only one way to use the movie ability. Here are some other ideas:

        * movies can also record the whole interface.
        * you cans switch between recording the interface and the graphics
        (the view) in the same movie.
        * setup the movie when "setup" is run, grab the movie frames inside GO
        itself, provide a button to close the movie after go stops.
        * program go so that it knows when it is about to be done, so it can
        close the movie itself
        * add a switch to indicate whether or not a movie will be recorded.
        * for slowly developing models, don't record a frame every timestep,
        rather record a frame every 10, 365, or 1000 time-steps.
        * program the model to detect when something "interesting" happens in
        the model, and only then record a frame (or a few frames) to the
        movie.
        * same thing, but also make the model keep track of recent activity
        (i.e. maintain an "undo" list), so that when something "interesting"
        happens, the model can roll itself back a few ticks, and replay the
        timesteps leading up to that event, recording them in the movie.
        * if a time-stamp would be useful, use a large-font and a patch label
        to show the ticks or other time unit in the model.
        * include a rotating "clock" in the view (as in some of the newer
        library models) to show the passage of time

        Hope this helps!
        ~~James

        to setup
        ;; setup a simple demo of turtles moving
        ca
        cct 20
        [ jump 1 ]
        end

        to go
        ;; make the turtles move around
        ask turtles
        [ rt who
        jump 1
        ]
        end


        to record-movie
        ;; record and save a 31 frame movie, about 3 seconds long

        ;; run your setup procedure
        setup

        ;; if for some reason a movie is in progress, cancel it.
        movie-cancel
        ;; (this happens when a run-time error occurs
        ;; in the middle of recording a movie, so that
        ;; movie-close never happens. This is not as
        ;; important once a model is "mature" and has
        ;; less change of runtime errors

        ;; initialize the movie
        ;; use whatever filename you want
        ;; (or add a way to allow the user to specify the file and location)
        movie-start "out.mov"

        ;; set the frame-rate per-second
        movie-set-frame-rate 10
        ;; this means that 10 "steps" of your model will take 1 second of movie time.
        ;; 15 is the default, if you didn't use movie-set-frame-rate

        ;; save the first frame as the initial state of the model
        movie-grab-view

        ;; run the model's go procedure 30 times, then
        ;; record a frame of the movie after each GO
        repeat 30
        [ ;; run the model for 1 go
        go
        ;; record the result as a frame of the movie
        movie-grab-view
        ]
        ;; all done, now close the movie to save in the movie file
        movie-close

        end
        ;;; ~~~~~~~~~~~~~~~~
      Your message has been successfully submitted and would be delivered to recipients shortly.