|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false% k# |0 o8 F) d. F6 F& p+ |
to go
4 x6 @( ^! z. ~' b/ Zif not any? turtles with [not stopped? ] [ stop ]
; X3 T- U6 h% n$ [* z- Aask turtles with [remainder who 5 = 0] [
4 P! F3 p6 x+ M0 Mset close-mates (turtles with [self != myself])with[
! Z, v6 _" A: c9 Y1 T" `" j(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
' o( b" T& _: x$ ^and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 9 w4 c+ E+ H+ X u- s, W0 d
and remainder who 5 = 0
7 W4 E: ?* ^: C7 W* a6 W/ N- r]
/ A4 {) U3 w- B! d% x4 ]+ z2 ^ifelse any? close-mates
6 @+ B% v5 Z; G[ ! z5 ]0 {1 A5 r
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
9 l: E, c. p3 `) Q7 [face closest-one
- Y5 Z9 e3 a8 z+ h- mrt 180
% Z2 z4 Q# E- E3 K! @9 @; `fd random-float step-size5 D/ Q$ {5 U9 @$ s
avoid-walls
2 s/ P! Y/ e) e2 t$ J, G: sset stopped? false]: M; `/ I6 C5 y0 c
[set stopped? true] ) N7 f4 e1 {5 N# K
] |
|