我需要在世界范围内实现小多边形的运动 补丁的着色方式如下: 1)呈蓝色的大椭圆形(适当的补丁是蓝色的)
2)里面有两个绿色的圆形(适当的补丁是绿色的)
每个圆形在其边界“都”具有多个隧道龟
我有几只多边形的乌龟,最初是放在绿色圆圈内(polygonInside
)
我需要多边形在圆内运动,直到它们撞到隧道之一。之后,它们将仅在椭圆形内移动(不返回圆形)。我创建适当的polygonOutside
而不是polygonInside
我尝试过:
ask polygonInside [
let step 0.7
ifelse (green = [pcolor] of patch-ahead 0.7)
[
rt random 90
lt random 90
]
[
ifelse any? turtles with [ shape = "tunnel" ] in-radius 1.3
[
hatch-polygonOutside 1
[
set shape "polygon"
move-to min-one-of neighbors with [pcolor = blue] [distance myself]
]
die
]
[
face min-one-of neighbors with [pcolor = green] [distance myself]
]
]
fd step
]
ask polygonOutside [
ifelse ((blue = [pcolor] of patch-ahead 1))
[
rt random 90
lt random 90
]
[
; !!!!they are stucked
; move-to min-one-of neighbors with [pcolor = blue] [distance myself]
; !!!!sometimes runtime error
face min-one-of neighbors with [pcolor = blue] [distance myself]
]
fd 0.7
]
几乎可以,但是有两个问题: 1)多边形在外面时非常接近绿色圆圈(几乎相交) 2)有时我会从
收到运行时错误face min-one-of neighbors with [pcolor = blue] [distance myself]
任何人都建议如何解决它们?