|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false3 ^% y- C! _5 c: S: g, @
to go; [" A3 `( p) {0 f; q
if not any? turtles with [not stopped? ] [ stop ] 9 w$ r3 k- [4 F5 @) C1 ]
ask turtles with [remainder who 5 = 0] [
. F: G" ?9 w- [set close-mates (turtles with [self != myself])with[9 K) x% O+ h) J% @& {- r+ r$ S
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 9 G) [ S7 W( g+ B" {9 }
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) h8 r, m4 @- q" [
and remainder who 5 = 0 ! \6 R) u4 W/ D% K
]
T" }' B) @3 r# w* U2 {3 gifelse any? close-mates
8 ?7 y7 k- n- N8 e& h[ 8 V/ T, Y' G7 Y/ B4 W/ D
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]" c( @4 r8 x1 ~( { ]% H' Q
face closest-one% d9 E5 C7 U9 |: |; z
rt 180
4 {" A" x0 @7 q0 s& F' Bfd random-float step-size; ~/ B+ S; s ^3 n4 r1 I9 x% J
avoid-walls8 r- \+ b; l6 f1 a' H3 i
set stopped? false]
* a0 d( ?2 \3 r% ^ i[set stopped? true]
( R- q# F, x- N9 j] |
|