简体   繁体   中英

Netlogo: resetting event every tick, but tick counter goes on

Trying to let a flood appear with every tick and make it disappear after every tick as well. Meanwhile, the tick counter should go on. The flood appears this way:

to water_rise
 ask patches [  ; saturates cell
  if is-DEM < 800[
      set cell-storage cell-storage + fill-rate
    ]
  ]

  ask patches [
    if any? neighbors4 with [ any? turtles-here ] [
      set cell-storage cell-storage + fill-rate
    ]
  ]
  ask patches [
    if cell-storage > 0 [
      if cell-storage > 5 [
        set cell-storage 5
        if not any? turtles-here [
          sprout 1 [
            set color blue
            set size 10
            set shape "circle"
          ]
        ]
      ]
      set pcolor cell-storage + 82
    ]
  ]
end

Currently trying to figure out how to let the flood disappear after/or within this the tick, so that it can reoccur in the next one. I´m not aiming to reset the tick counter, it should reach 200. Tried resetting the ticks, but only to manage resetting everything.

Any ideas? Thank you very much in adavance

Cheers

You can simply use the display primitive to update the view without waiting for the tick counter to advance.

I am not familiar with your whole model but here's a conceptual example that may help:

to water_rise
  ...
end
    
to go
  repeat 100 [
    water-rise
      display
    ]
  tick
end

This code would execute your water-rise procedure 100 times, update the view with new patch colors after each execution, and only increase the tick counter by 1 after the repeat loop is done.

Here is the link to NetLogo Dictionary entry about the display primitive: http://ccl.northwestern.edu.netlogo/docs/dictionary.html#display

Note: due to its design, NetLogoWeb does not support the display primitive. So, you need to use the desktop version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM