简体   繁体   English

Netlogo:海龟从其他海龟继承事件

[英]Netlogo: Turtles inherit event from other turtles

How to let other turtles inherit event from other turtle? 如何让其他乌龟继承其他乌龟的事件? In my code I have this simple setup that has 50 turtles. 在我的代码中,我有50个海龟的简单设置。 I have also a panic button that if it is clicked some turtle will set their mood to panic and color to orange. 我还有一个恐慌按钮,如果单击该按钮,某些乌龟会将他们的心情设为恐慌,将颜色设为橙色。

I have some changes with this one. 我对此有一些改变。 Disregard the percentage. 忽略百分比。 Now all turtles will check around them if they found/see turtles with mood = panic and color orange they will also go to panic and color orange. 现在,所有乌龟都会检查周围的动物是否发现/看到心情=恐慌和橙色的海龟,并且也会惊慌并变成橙色。

turtles-own[
 mood
]


to setup
  __clear-all-and-reset-ticks
  create-Humans
end


to create-humans
  crt 50[
    setxy random-pxcor random-pycor
    set color blue 
    set mood "calm"
  ]
end


to panic
  ask n-of initial-panic turtles [
    set mood "panic"
    set color orange
  ]

end

模特形象

I tried this. 我试过了

to go
  ask turtles[
    fd 1
    lt random 90]

  ask turtles[ 
    ask turtles in-cone 3 60
    [ if any? turtles with [ color orange]
        set mood "panic"] ]  

end

But it doesn't work. 但这是行不通的。

welcome to StackOverflow, you can try this: 欢迎使用StackOverflow,您可以尝试以下操作:

turtles-own[
 mood
]


to setup
  __clear-all-and-reset-ticks
  create-Humans
  panic
end


to create-humans
  crt 50[
    setxy random-pxcor random-pycor
    set color blue 
    set mood "calm"
  ]
end


to panic
  ask n-of initial-panic turtles [
    set mood "panic"
    set color orange
  ]

end


to go


  ask turtles[ 

    fd 1
    lt random 90

    if any? turtles in-cone 3 60 with [ color =  orange]
      [set mood "panic"
        set color orange
      ]
  ] 

end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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