|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
/ ~- O# ^& R8 z2 W- W" o% p: Y7 yto go
# o% E# A. L; y! y9 F$ u( wif not any? turtles with [not stopped? ] [ stop ] 3 r2 e" S& @$ L" K$ {
ask turtles with [remainder who 5 = 0] [
; a3 I1 Z# g' N2 w0 J( X2 y) l$ G4 _set close-mates (turtles with [self != myself])with[. P0 g0 ~; i+ i: {% m
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) + D2 S+ Y$ V$ ~, d: u7 }+ O, Y
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
, B) q# d5 T& [/ |and remainder who 5 = 0
- w9 P% L) S4 E5 f% p]
) _& ? \8 n+ J- H) c' l# {9 Zifelse any? close-mates
2 s9 G% H! D+ P% B- i# R0 k3 K[
4 ^: }0 A6 ]% i5 `( nset closest-one min-one-of (close-mates with[self != myself] )[distance myself]) ~: D+ a" `1 `) P5 G0 t8 w+ [# D
face closest-one
/ w4 Z/ f' V6 X9 Z5 d! Zrt 1801 _0 C# c- i7 `3 q1 r. C
fd random-float step-size/ y8 A7 m( A* p9 l" E# H& _
avoid-walls
- j% V, h+ [: x1 J1 I l4 }set stopped? false]$ D5 f8 J- g# k3 X$ L& @ z
[set stopped? true] 7 m' P8 L! g, N1 n% m4 v
] |
|