Netlogo hide-turtle

时间:2015-02-14 16:56:48

标签: hide netlogo turtle-graphics

这是一个Netlogo-beginner问题。我创造了一个模型,鸟类将在某条路线上飞行。我创建了这条路线,将10只海龟放在贴片上,称为“rasts”(休息处),将它们相互连接起来。现在,我想让鸟儿在这些路线上飞行,当一个休息的地方消失时(通过使用“开/关” - 开关),他们将采取另一条路线。 我的问题:目前我有5个rasts,但只有第一个可以通过使用开关关闭。有人有想法,如何解决这个问题?

这是我的代码:

breed [rasts rast]
breed [birds bird]

to setup
 setup-rasts
 hide-rasts1 
 hide-rasts2 
 hide-rasts3 
 hide-rasts4
 hide-rasts5
end 

to setup-rasts
 set-default-shape rasts "circle"                  
 create-rasts 1 [setxy -12 36 ]
end

to hide-rasts1                                        
 ifelse rast-1? [ ask rast (number-of-birds + 0) [ set hidden? true] ]
               [ ask rast (number-of-birds + 0) [ set hidden? false] ]
end

1 个答案:

答案 0 :(得分:2)

对于第一个问题:

  
      
  1. 是不是可以通过使用它来制造超过1只龟   以下代码?
  2.   

你可以要求隐藏海龟名单:

; hide all turtles
ask turtles [ hide-turtle ]
; hide all your "rasts"
ask rasts[ hide-turtle ]
; hide random 4 of your turtles
ask n-of 4 turtles [ hide-turtle ]

关于2.问题

  
      
  1. 是否有可能让乌龟(鸟类)遵循改变它的路线,   那边还有另一只乌龟(rast)吗?
  2.   

答案当然是可能,但问题是以某种方式提出一个精确的解决方案。您可以使用face命令将乌龟指向正确的方向。为了感应最近的海龟,请检查最小距离的海龟。例如(在乌龟的背景下):

set nearest-rast min-one-of (other rasts) [ distance myself ]