|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
' [' P5 I' H/ s2 \6 ito go
0 I# |: }7 Y9 B$ fif not any? turtles with [not stopped? ] [ stop ] + ?) q8 K/ n9 z- s' c
ask turtles with [remainder who 5 = 0] [
5 B5 E* b9 ~7 O2 ~5 W! b0 a0 oset close-mates (turtles with [self != myself])with[8 Y4 u1 I! E% p1 b0 U2 ]
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) # ^0 m( S M& E* m+ _
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 1 [( s6 G3 Y% A& k* C( x
and remainder who 5 = 0
, r u4 V9 P. E3 |, q]
4 m9 \: _' N" G) G2 Fifelse any? close-mates ) b$ U, q( P8 N2 u
[
6 }" |" t1 D |. z7 fset closest-one min-one-of (close-mates with[self != myself] )[distance myself]* r9 i1 V6 U0 K4 _0 G, E8 S, `
face closest-one' s& y s( T8 {
rt 180' d( h# W, l% H' m3 S
fd random-float step-size
6 V& X$ \: t8 H) _- b& ~4 z( javoid-walls$ ~! b' H6 D9 a9 A
set stopped? false]
& R$ f. y1 ^# K4 Z[set stopped? true]
$ I/ [' U1 p' v7 Z0 N. T] |
|