|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
, D6 x* j" t# k* u& p6 `to go
9 H! ^3 @5 O% ~( P8 @# J% ^if not any? turtles with [not stopped? ] [ stop ] ; \7 p4 K+ [- q; @' g# |; z
ask turtles with [remainder who 5 = 0] [4 i' p( t* I7 P5 P1 U
set close-mates (turtles with [self != myself])with[
( c+ p! F; G' L(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
2 ]! O2 Q/ M. t- _+ L* i2 @and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ( M* ]# s& O$ T" @
and remainder who 5 = 0
7 U( b8 d3 e% b& t] ! d% \. W% o. {4 `% `
ifelse any? close-mates
* a( @$ t7 G5 P6 _6 R[
2 G8 J2 s; I' Aset closest-one min-one-of (close-mates with[self != myself] )[distance myself], |2 a4 E/ a, f
face closest-one- s. ^& Y, g2 X) @+ r
rt 180
& |' w6 D9 _+ [$ c- x: Tfd random-float step-size
: F" K5 [& c# \5 qavoid-walls
$ e' N2 S8 h* y" W4 cset stopped? false]9 P/ j" _. ^8 c: m: A9 ^$ j
[set stopped? true] ; P6 L) n. k9 m
] |
|