netlogo: how to make turtles stop for a set number of ticks then continue

前端 未结 2 2022
逝去的感伤
逝去的感伤 2020-12-21 01:24

I\'m trying to create a model where turtles walk randomly (but with a tendency for forward movement) until they land on a yellow coloured patch which represents a baited obj

2条回答
  •  没有蜡笔的小新
    2020-12-21 01:47

    This is just one example, How many ticks they should stay in the yellow area? i Assumed 15 ticks and I ask turtles to print their tick number on their label too, if it runs too fast you might miss their stay so adjust running speed for your model to see when they stay and when they move. You can have different methods to continue , in this one they just move 1 patch forward.

    turtles-own [count-down]
    
    to setup 
      clear-all
      ask patches with [count neighbors != 8]
      [set pcolor blue]                   
    
      create-turtles 20
      ask turtles 
      [setxy random-xcor random-ycor 
        pen-down
        set count-down 15
      ]   
    
      ask n-of 20 patches
      [ set pcolor yellow ]                   
    
      reset-ticks
    end
    
    to go
      move-turtles
      tick
      if ticks >= 720 [stop]
    
    end
    
    
    to move-turtles
      ask turtles
      [ ifelse pcolor != yellow
        [continue]
        [stay]
      ]
    end
    
    To continue   
      rt random 10
      fd 1 
    end
    
    
    to stay   
      set count-down count-down - 1   ;decrement-timer
      set label count-down    
      if count-down = 0 
        [
          Continue
          set label ""
          reset-count-down
        ]    
    
    end
    
    to reset-count-down   
      set count-down 15 
    end
    

提交回复
热议问题