|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
& l1 N8 M: }2 P8 Hto go1 ?& f3 f3 u8 B2 Q) ^7 z! K2 l- |
if not any? turtles with [not stopped? ] [ stop ] & q! B% G0 v5 ^" @6 ]' U
ask turtles with [remainder who 5 = 0] [
. p& o# Z$ P8 ?" b) Wset close-mates (turtles with [self != myself])with[
; r& q- C) r+ z. _% p; X" N(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
! ^: L! F W1 L* n6 K @4 A3 ~and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
+ E& q' {! ` O8 I/ u3 Sand remainder who 5 = 0
1 v( D3 A _9 A- J] 8 b% x: ?5 E7 n6 L
ifelse any? close-mates
?% w) i; k- [$ l6 N[ # q. {$ {; w, Y1 W5 s9 f
set closest-one min-one-of (close-mates with[self != myself] )[distance myself], [$ A& V( ]9 X' U* ~
face closest-one) O( \9 J4 f0 y
rt 180
7 h/ X# p x Lfd random-float step-size5 L8 A4 y: z9 u( d8 g
avoid-walls/ B0 }6 E( l& }. {7 I" Q: I( B$ f
set stopped? false]9 Q8 a0 E% n4 A& E4 _ f
[set stopped? true]
6 |+ x2 u- L" P5 T, A5 a] |
|