Agnes de Araujo
Agnes de Araujo

Reputation: 71

How to record a simulation video in NetLogo

I'm trying to record a video of my model's simulation in NetLogo using the vid extension. I started recording at the beginning of the simulation and asked to record each view update. However, my video is only 1 second (1 tick). Because I asked to save the file in the end. How do I record 200 ticks of simulation?

extensions [ vid bitmap ]



      to setup
      clear-all
      ask patches [
    set pcolor black
      ]
        ask patch 0 0[set pstatus 10 set pcolor 5 set homeX pxcor set homeY pycor]
    create-turtles 10 [
     set breed ricos
     setxy random-ycor random-xcor
     decrease-value
     decrease-price
      ]

 set view-mode "pstatus"
  reset-ticks
end
to go

  vid:start-recorder
    locate-ricos

    ask infras [
    if counter > residents-per-infra
    [locate-infras
      evaluate-infra
      set counter 0]
    ]

  if count (ricos) >= 100 [kill-ricos]
  if count (medias) >= 80 [kill-medias]
  if count (pobres) >= 20 [kill-pobres]


  update-patch-color
  vid:record-view
  tick
  vid:save-recording "filme.mp4"
end

Upvotes: 0

Views: 840

Answers (1)

Luke C
Luke C

Reputation: 10336

Try something like this:

extensions [ vid bitmap ]

to setup
  ca
  crt 10
  reset-ticks
end

to go
  if vid:recorder-status = "inactive" [
    vid:start-recorder
  ]
  vid:record-view
  ask turtles [ 
    rt random 50 - 25
    fd 1
  ]
  tick
  if ticks = 200 [
    vid:save-recording "filme.mp4" 
    print vid:recorder-status   
    stop
  ]
end

The key is that you need to only call vid:save-recording when you meet some condition, otherwise it'll get called, report out the one frame, and get reset every single tick.

Upvotes: 1

Related Questions